Cast is invalid exception in Linq-to-SQL

An insert into a Table that has references to fields that have a unique index constraint is not supported in Linq-to-Sql and will throw an “Cast is invalid” exception.

Here’s a little example:


I have three tables, a Users and a Roles table. Both have a unique key. One has the UserName and the other the RoleName .
A new record to the reference table UsersInRoles can only be added if the Username and the RoleName exists.

This works fine in SQL Server, but it fails in Linq-To-Sql. Only, if I delete the references in the  Linq-to-Sql mapping file it works in Linq-To-Sql as well. Unfortunately that means, that I always have to remove the references by hand, when I recreate the tables from the SQL Server in the mapping diagram.

Enabling ftp services through firewall on Windows 2008

To enable ftp services on a Windows 2008 Server it’s unfortunately not enough to add an exception of the FTP Server in the white list of the built-in firewall in Windows.

Although, Windows has an exception list template for the FTP Server, it doesn’t work and your client will not connect to the FTP Server.

The reason I heard and what makes sense to me is, that the template is pointing already to the new FTP Server which is shipped in Windows 7 and is part of the new IIS7, but not in Windows 2008.

I added a new exception to the program c:\windows\system32\inetsrv\inetinfo.exe which is actually the IIS6 FTP server and now ftp services are working through the firewall again.