Send SmtpClient Mails to Disk

When developing a system that sends mails, often the mails shouldn’t be sent for real when testing. Instead they should be made available for investigation. Fortunately, that functionality is built in with the .NET SmtpClient. There is even no need to change the code. It’s just a matter of configuration. Add the following lines to… Continue reading Send SmtpClient Mails to Disk

Dynamic Overload Resolution

Both when coding in C++ and C# I’ve had problems with overload resolution being static. There are workarounds, for example the visitor pattern but it requires quite an effort to implement. More importantly it cannot be implemented without changing the visited element. With C#4’s dynamic keyword there is finally a better solution. To illustrate the problem… Continue reading Dynamic Overload Resolution

Debugging a WCF Service Using a 32 Bit Dll

Recently I was involved in a problem where we had a WCF service referencing a 32 bit dll. The service was set to to “Start WCF Service Host when debugging another project in the same solution”. Unfortunately that ended up with an exception. Could not load file or assembly ‘My32BitLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’ or one… Continue reading Debugging a WCF Service Using a 32 Bit Dll

EF Code First Navigation Properties and Foreign Keys

An Entity Framework Code First class corresponding to a table with a foreign key typically has two fields for the foreign key. The foreign key as represented in the database and a C# reference. [ForeignKey("BrandId")] public Brand Brand { get; set; }   [ForeignKey("Brand")] public int BrandId { get; set; }[ForeignKey("BrandId")] public Brand Brand {… Continue reading EF Code First Navigation Properties and Foreign Keys