Solved: The C++ module failed to load while attempting to initialize the default appdomain.

By dsandor at July 02, 2010 20:37
Filed Under: Programming

Summary of Errors:

Exception of type 'System.Web.HttpUnhandledException' was thrown.

The type initializer for '' threw an exception.

The C++ module failed to load while attempting to initialize the default appdomain.

Illegal operation attempted on a registry key that has been marked for deletion.

 

The full ugly error:

System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: The type initializer for '' threw an exception. (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is: System.TypeInitializationException: The type initializer for '' threw an exception. ----> System.TypeInitializationException: The type initializer for '' threw an exception. ----> .ModuleLoadException: The C++ module failed to load while attempting to initialize the default appdomain. ----> System.Runtime.InteropServices.COMException: Illegal operation attempted on a registry key that has been marked for deletion. (Exception from HRESULT: 0x800703FA) at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at .GetDefaultDomain() at .DoCallBackInDefaultDomain(IntPtr function, Void* cookie) at .LanguageSupport.InitializeDefaultAppDomain(LanguageSupport* ) at .LanguageSupport._Initialize(LanguageSupport* ) ...). --- End of inner exception stack trace --- at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.fieldreceiptdetail_aspx.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Solution:

This problem was related to a cross-appdomain failure.  We are using the Microsoft Dynamics AX 2009 Business Connector in this application.  The Business Connector is a C++ application that we use to talk to AX.  From what I can gather, there are two applications using the C++ DLL at the same time.  The problem is that the DLL is mixing appdomains because of our Application Pool setup in IIS 7. 

image

So to solve the problem, I created a new Application Pool for this application.  I also set the pipeline mode to Classic.  This solved the problem for me.