I’ve spent the last couple of hours trying to get a web application working. The problem was that the web application uses a custom Principal object, implementing IPrincipal interface, but upon launching the application in Visual Studio, a strange exception was thrown.

The exception signified that the custom principal class is not serializable, so I naturally made it so, but another exception was thrown further along the way.

Turned out that this is a bug that happens only if you run your application inside Cassini webserver that comes with Visual Studio and there’s really nothing wrong with the code and implementation. A good explanation of why this happens is here. There are two ways to make this work, either use IIS to launch the application or deploy the assembly containing custom principal to GAC.

The problem may have been solved in Visual Studio 2010 which I haven’t tested with yet. After actually finding about the problem and searching the internet, I found out that the bug is reported back in 2005, so I wonder how come the bug that is reported in 2005 is still there in Visual Studio 2008?

Some old not generally known bugs can still bit you.