I’m facing a problem with an external DLL after application pool time out.
I’m using VS2010 with a C# web application and .NET 2.0. This application include a external DLL (wrote in C++). This DLL is Referenced in the project so in the ObjectBrowser I could see the Assembly and all the functions.
The DLL required anothers DLL’s that I installed them in a c:\DLL directory and added this directory to the EnvironmentVariables “Path” at Application_Start() function.
The application works correctly all the times except after Application time out. (It has the 20 minutes default time out).
The next time I run the application after the time-out I got “The type initializer for ” threw an exception.” in the function that do a new object of the DLL assambly
Another option to throw the error is to “End the process” for “w3wp.exe” in Windows Task Manager / Processes. After end the process and refresh the application the error is displayed.
Thanks
Edited:
Inner Exception:
at <CrtImplementationDetails>.ThrowModuleLoadException(String , Exception )
at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* )
at .cctor()The type initializer for '<Module>' threw an exception.
After implemented removing cookies I found the same issue with other scenarios.
So digging more I found the Real issue was my unmanaged DLL had a conflict with a Class that inherent from IPrincipal:
So I found the solutions in these links:
The type initializer for ” threw an exception
and
Error on DataPortal with Loading assembly msvcm80
So now the definition of my class is: