1
votes

I have a managed DLL that internally references a couple of unmanaged DLLs. This managed DLL is added as a reference to my WCF service project. However, the unmanaged DLLs have to be manually copied to the build output path of my project. They cannot be referenced within Visual Studio.

If I try to run my service DLL within the WCF Service Host in Visual Studio, latter crashes without any exceptions and automatically restarts. Sampe applies if I try to host service DLL in IIS. I was able to catch one of the WERReportMetadata crash logs when trying to host in IIS and the ProblemSignatures says:

<ProblemSignatures>
    <EventType>CLR20r3</EventType>
    <Parameter0>webdev.webserver40.exe</Parameter0>
    <Parameter1>10.0.0.0</Parameter1>
    <Parameter2>4d5f345a</Parameter2>
    <Parameter3>GTAPIASM</Parameter3>
    <Parameter4>2.0.5.0</Parameter4>
    <Parameter5>4e9254a5</Parameter5>
    <Parameter6>166</Parameter6>
    <Parameter7>23</Parameter7>
    <Parameter8>System.AccessViolationException</Parameter8>
  </ProblemSignatures> 

What does this mean and what can I do about it? Any reference material on WCF hosting with unmanaged DLLs will be useful too.

Edit 1: Copying the unmanaged DLLs to %systemroot%\syswow64 allows me to host my service using Visual Studio WCF Service Host. I got the tip from here. However, this does not stop WebDev.WebDServer40.exe from crashing.

Edit 2 This is .NET Runtime error captured from Event Viewer:

Application: WebDev.WebServer40.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.TypeInitializationException Stack: at System.RuntimeMethodHandle._InvokeConstructor(System.IRuntimeMethodInfo, System.Object[], System.SignatureStruct ByRef, System.RuntimeType) at System.RuntimeMethodHandle.InvokeConstructor(System.IRuntimeMethodInfo, System.Object[], System.SignatureStruct, System.RuntimeType) at System.Reflection.RuntimeConstructorInfo.Invoke(System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo) at System.ServiceModel.Description.ServiceDescription.CreateImplementation(System.Type) at System.ServiceModel.Description.ServiceDescription.SetupSingleton(System.ServiceModel.Description.ServiceDescription, System.Object, Boolean) at System.ServiceModel.Description.ServiceDescription.GetService(System.Type) at System.ServiceModel.ServiceHost.CreateDescription(System.Collections.Generic.IDictionary`2 ByRef) at System.ServiceModel.ServiceHostBase.InitializeDescription(System.ServiceModel.UriSchemeKeyedCollection) at System.ServiceModel.ServiceHost.InitializeDescription(System.Type, System.ServiceModel.UriSchemeKeyedCollection) at System.ServiceModel.ServiceHost..ctor(System.Type, System.Uri[]) at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(System.Type, System.Uri[]) at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(System.String, System.Uri[]) at System.ServiceModel.ServiceHostingEnvironment+HostingManager.CreateService(System.String) at System.ServiceModel.ServiceHostingEnvironment+HostingManager.ActivateService(System.String) at System.ServiceModel.ServiceHostingEnvironment+HostingManager.EnsureServiceAvailable(System.String) at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(System.String) at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest() at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest() at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(System.Object) at System.Runtime.IOThreadScheduler+ScheduledOverlapped.IOCallback(UInt32, UInt32, System.Threading.NativeOverlapped*) at System.Runtime.Fx+IOCompletionThunk.UnhandledExceptionFrame(UInt32, UInt32, System.Threading.NativeOverlapped*) at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)

Edit 2:

Turns out I have to run Visual Studio as admin at all times. This eliminates the previous error.

Thanks.

1

1 Answers

0
votes

I needed to add unmanaged DLLs to %systemroot%\syswow64. Did this and can run my service in WCF Service Host in Visual Studio as well as ASP Development server.