Assembly.GetEntryAssembly() is tricky.

So something I learned when I was getting Exor ready for publication and was reminded of when I hit a bug with TiledSharp last night was that Assembly.GetEntryAssembly() has a trap door in it. Something a lot of people, myself included, seem to forget is that you can load managed assemblies from unmanaged code in .NET. When you do this, GetEntryAssembly() returns null.

This is documented, but in the regular case you won’t see this–your app runs, you get the entry assembly you expect, life is good. The unit test runner in Visual Studio (at least as of 2013), though, calls through unmanaged code. So does the XNA content pipeline, which I’m otherwise using happily with MonoGame.