Friday, November 9, 2007

FileLoadException when loading C++/CLI module

I created assembly in C++/CLI with some unmanaged code inside. Everything worked perfect as long as it was the executable which I was starting. But later I created some UI in C# which was wrapping that that C++ assembly. And got the problem:

System.IO.FileLoadException: Attempt to load an unverifiable executable with fix ups (IAT with more than 2 sections or a TLS section.) (Exception from HRESULT: 0x80131019).

Solution is that you change C++ assembly from EXE to DLL! There is probably some linker optimization during EXE loading which is not supported by CLR loader.

No comments: