5YrsLaterDBA
5YrsLaterDBA

Reputation: 34740

TypeInitializationException for Visual Studio 2008

Trying to setup my laptop to edit and run my C# application which called C++ dll. compile is ok, but when I run it, TypeInitializationException was unhandled error happened.

It said: The type initializer for '<Module>' threw an exception.

I also installed Visual Studio 2008 sp1.

No any problem at my desktop computer. Same OS, windows XP.

any idea?

Upvotes: 0

Views: 418

Answers (2)

Tim Robinson
Tim Robinson

Reputation: 54724

Run the app under the debugger and take a look at the InnerException property - it should tell you what failed.

Alternatively, set up the debugger to break on every exception, instead of the default behaviour of only breaking on unhandled exceptions. It should take you to the line of code that fails.

If that doesn't help, and you built the C++ DLL yourself, turn on unmanaged debugging via the properties for the C# project. This will allow you to step into the C++ code and track down the original error.

Upvotes: 1

Mike Marshall
Mike Marshall

Reputation: 7850

In my experience this means that you are missing one of your libraries reference assemblies or Dlls or that a constructor of one of your objects threw an exception.

Upvotes: 0

Related Questions