Category Archives: Windows

Relationships in Entity Framework Code First

In this article I will describe a common mapping problem with relationships in Entity Framework Code First. I once had this problem as well and got the answer from StackOverflow (if interested, see my question here).

Consider the following models:

And the following (psuedo)code to save a ClassA:

Continue reading Relationships in Entity Framework Code First

MSBuild task to compile LESS files

When you are using LESS to create dynamic style sheets the performance of your website will increase when you compile those files to CSS before uploading the webapplication to a server. In this post I’ll describe how to create a build task for MSBuild that will compile all LESS files in a directory. I use this task in my deployment environment for web applications. It is part of a series of tasks that build the application, copies all the files to a deployment directory and does some post processing (compressing JavaScript, images, etc.). Of course it is possible to compile LESS files dynamically using a HttpHandler as well, for more information visit dotless.org.

Continue reading MSBuild task to compile LESS files

Fix hMailServer 550 Invalid HELO string error

On a web server I’m running hMailServer to handle all e-mail traffic, especially SMTP. Today I noticed in some cases the e-mail hMailServer sent was rejected by the receiving party. It turned out the receiving party was a Microsoft Exchange environment. The hMailServer SMTP log stated the following:

On the internet I found this topic. The solution to this problem is as follows: in the hMailServer administrator go to Settings > Protocols > SMTP > E-Mail Delivery tab. Enter the host name of your web server (e.g. a domain name) in the “local host name” field, and save the changes. Now the Exchange server will accept your e-mail.

 

Simple logger for NHibernate 3

A logger is a very useful tool when developing a (web)application, especially when you’re using an object-relation mapping solution such as NHibernate or Entity Framework. In order to improve the performance of your application it is useful to analyze the SQL queries and other information (e.g. warnings, errors, caching) about the object-relation mapping.

Since NHibernate 3 it is possible to implement a custom logger. Log4net is not necessary anymore. In this post I’ll describe how to implement your own logger.

Continue reading Simple logger for NHibernate 3

Fix .NET 4 SocketPermission for MySQL driver in Medium Trust

Most .NET 4 shared hosting providers offering their customers a medium trust environment. This is not a problem for most web applications unless the applications uses MySQL in combination with the .NET MySQL driver (MySQL.Data.dll). The MySQL driver connects to the MySQL database using a socket. However, sockets are not allowed in medium trust. The application will throw a SecurityException with the following message:

Continue reading Fix .NET 4 SocketPermission for MySQL driver in Medium Trust

Possible solution for NHibernate many-to-many criteria

In one of my .NET projects I’m using the NHibernate library for object-relational mapping. I’m mainly using the ICriteria interface to fetch data from the database. Unfortunately I ran into a function that got really complicated; how to query a many-to-many relationship. For example, I have a table containing posts and a table containing tags. The post datamodel contains a set with tags so in my mapping it’s a many-to-many relationship. I want my query to return all posts tagged with one or more specific tags. On this forum I found a solution. I’m not sure if this is the perfect solution, so feel free to suggest a better one.
Continue reading Possible solution for NHibernate many-to-many criteria

Using log4net to show NHibernate SQL in Visual Studio

I’m currently developing a web application in ASP.NET MVC and NHibernate. Since the application was very slow at some points I wanted to know which SQL queries NHibernate was executing. Since the log4net library was already included in the application I searched for a solution to output the SQL queries to the console in Visual Studio 2010 using log4net. I found the solution on this wiki and this blog post.

Continue reading Using log4net to show NHibernate SQL in Visual Studio

How to lookup MIDI notes of your MIDI controller

Last week I helped Bas verifying his MIDI layout of the Reloop Digital Jockey 2 interface and controller edition. I used a program for Windows called MIDI-OX, a diagnostic tool for the MIDI protocol, to do this. In order to lookup the MIDI information sent by your MIDI controller turn on your device, start MIDI-OX and go to Options > MIDI Devices.

Continue reading How to lookup MIDI notes of your MIDI controller

How to stop Traktor from editing ID3 tags

A few days ago I was trying a demo version of Traktor Pro. When playing some tracks I discovered the ID3 tags were missing when viewing the files in Windows Explorer. According to this topic Traktor changes the ID3 tags from version 2.3 to version 2.4 which can’t be read by Windows 7, so it’s not really a bug but rather annoying. In this post I’ll describe how to run Traktor as a different user in Windows 7 so it has no permissions to modify files any more. This solution is mentioned in this topic.

Continue reading How to stop Traktor from editing ID3 tags

Getting started with LaTeX and BibTeX in LEd

Recently I started writing a simple paper in LaTeX. Since I was only used to editors like Word and OpenOffice writing in LaTeX was completely different. In this post I’ll describe how to get started with LaTeX and BibTeX in a simple and free LaTeX editor for Windows called LEd. First of all, download LEd here and install it on your system. Make sure you install MiKTeX, a Windows implementation of Tex, as well if you not already have it.

Continue reading Getting started with LaTeX and BibTeX in LEd