Debugger:: An unhandled non-continuable exception was thrown during process load

Posted on | 159 words | ~1 min
C# Debugging

The following exception can be a very tricky one to deal with:

Debugger:: An unhandled non-continuable exception was thrown during process load

here's some tips if you get it.

  1. Are you linking to winmm.lib? If so avoid it - it can cause these problems.
  2. Are you delay-loading the module? If not, try it - this can often resolve this issue if other modules like winmm.lib are interfering with the module that causes this exception.
  3. Are you using C++/CLI for the excepting module? If so, try using #pragma pack around exported class definitions.
If you haven't specified packing - do so. This is good practice anyway. I've used libraries that change the packing (which is very bad behaviour) before and this has caused all sorts of problems, so try and do the following:
// Push packing options, specify the packing.
#pragma pack(push, 1)

// Exported class class MY_API MyClass { public:

//	...etc

};

// Restore packing options.
#pragma pack(pop)