Search code examples
wpfunmanagedmanagedloadlibrary

Stackoverflow exception in windowsbase.dll when loading an unmanaged dll in managed aplpication


I am trying to load an unmanged DLL using loadlibrary from a a managed applciation every now and again when making a call on the dll I get a stackoverflow exception:

"An unhandled exception of type 'System.StackOverflowException' occurred in WindowsBase.dll"

The dll has been well used in other MFC applications so I don't believe it is a problem with that.


Solution

  • Just in case anyone hits the same problem this was being called as the DLL i was calling was a Borland DLL which threw exceptions, causing WPF to blow up. wrapping the DLL and calling it in a separate thread resolved the issue.