Reputation: 2909
Having a c++/cli project and it's a windows application. In debug mode we didn't have any problems but after taking it to release mode this error start up. I searched and found some forum-answers but couldn't help me solve this problem.
Please help me ....
Error :
An unhandled exception of type 'System.TypeInitializationException' occurred in Unknown Module
Additional information: The type initializer for 'Module' threw an exception.
Upvotes: 1
Views: 5013
Reputation: 160
I had the same problem and it got fixed after I install Visual Studio 2015 Redistributable x64 and x86.
Install VS C++ 2015 Redistributable (both x64 & x86)
Make sure you install both the x64 and x86 versions.
Hope this should fix the issue.
Upvotes: 0
Reputation: 942109
In a C++/CLI project, the <Module>
class is special (note the angle brackets). It is a hidden managed class that the compiler generates to give all of your functions that are not methods of a class a safe home. Required because the CLR does not support free functions like C++ does.
The type initializer for <Module>
is extra special, it runs very early at the start of the program. That's where the CRT gets started and any static objects in your code get initialized.
So the basic diagnostic you have is that the initialization of a static object in your code failed. That this happens at startup and only happens in the Release build is very, very painful. The debugger doesn't let you step through this code and of course you don't have good debug info to start with in the Release build. With some luck, the root cause is a C++ or SEH exception that didn't get handled. Debug + Exceptions, tick the Thrown checkboxes. The debugger will stop when the exception is thrown.
Upvotes: 5
Reputation: 1752
Does the machine where the application is running has all the required dlls??
I strongly believe that you are missing some interops in the local directory
Upvotes: 0