The type initializer for +’System.Windows.PresentationSource’ threw an exception.

I had an issue with a 3rd party control. I couldn’t blame them too much since the issue only happened in the WPF control hosted in a MFC C++ application. brutal for sure.

Why host WPF in C++? That is a question for another time, but let’s just say its an app written in the early 90’s and still has been rewritten, just bolted on and refactored.

Well, I created the test application and it worked great on my machine at home. I loaded it into my work computer and blammo, it threw up on the get handle call. WTF?

If you step into the .NET source(slow but very helpful), you get this.

System.Runtime.Versioning.BinaryCompatibility.ParseTargetFrameworkMonikerIn/toEnum in the call stack. and  NULL parameter exception.

Turns out through some goofiness in VC++, it will insert a null value in a manifest.

The fix is really easy. Delete all the files in your AppData\Local\Temp folder under your profile.

Here is a link to a guy who wrote about it in much more detail, but man that was non-intuitive fix. It worked though, so I am happy!

Thanks Microsoft for stealing another hour of my life. Thanks Telerik for being there to steal a week trying to reproduce bugs in your silly slow controls.

Happy coding!

 

Leave a Reply

Your email address will not be published. Required fields are marked *