Hosting WCF Service using unmanaged DLLs - iis-7

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.

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.

Related

IIS Error : Service cannot be activated due to an exception during compilation. What is it?

WebHost failed to process a request.
Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/14938877
Exception: System.ServiceModel.ServiceActivationException: The service '/xxxx.svc' cannot be activated due to an exception during compilation.
I have an ASP.NET app running on IIS. A dev created operation contract with same name as we had already. Fine in VS. However it fails when deployed on the prod IIS.
My question - what it has to do with compilation? Is there a conscious simple explanation whats happening in IIS with the app (in terms of post-deployment and hosting ASP.NET att)? What does it compile? What for?
My question - what it has to do with compilation?
Every time you run a .net managed process, the first thing which has to happen is that the .net VM (called the CLR) will compile the code in your assemblies (called MSIL) into machine code.
So IIS, as the hosting container, is providing this service for you.
As to the actual error you are getting, I would guess this is caused by something in the production web.config file being different to the development equivalent. Please post the System.ServiceModel configuration section of your web config and I'll have a look.

ServiceStack FileNotFoundException Deploying on IIS7

I developed a web service using ServiceStack (great framework, btw -- had fun using it) on .Net 3.5. The service runs fine on the dev box under IIS6. But when I try to deploy to a prod server running IIS7, I get the error:
[FileNotFoundException: Could not load file or assembly 'ServiceStack' or one of its dependencies. The system cannot find the file specified.]
I tried deployment via both xcopy (which I thought was sufficient for ServiceStack) and MSDeploy -- same error. The IIS7 virtual directory passes both authentication and authorization tests.
As mentioned, I'm not an IIS or ServiceStack expert. Might this be a registration or GAC issue? Any thoughts would be appreciated.

strange exception in ASP.NET web service when running on IIS

Got some strange problem.
I'm developing some complicated Web Services network that uses some VB6 .dll. In my previous post I got some problems with the dll but we've solved them.
So, the new problem is:
When I debug my service (those which uses VB6 dll) on development server from visual studio - everything works fine, the problem starts when I publish my service on IIS (I tried my local IIS). After that, when I call .dll method (as I understand I need to call it by reference - and that's what the compiler tells me) I got an exception:
"System.Runtime.InteropServices.COMException (0x800A000D): Type mismatch at ..."
Actually is happens here in the third line:
Object s = (Object)OrderId;
Object s1 = (Object)lines.Length;
proxy.OrderRead(ref s, ref s1);
OrderId and Legth are integers.
As I understant this is exception that comes from the .dll from vb6 :/
What the problem may be? Why it runs when debugging but fails on IIS?
When debugging in vb6,the IDE will register the dll for you. After publishing, have you may ahve to register your vb6 dll on the server. Open a command prompt and change to the location of the dll and run regsvr32 myvb6.dll.
Also, check these settings.
http://support.microsoft.com/kb/281630

Unmanaged dll called by ASP.Net unable to create file under IIS6

I have an ASP.Net Framework 4 web application making an interop call to a 3rd party unmanaged dll written in C++.
The dll is stored in the bin directory of the web application and creates a file in another directory of the same web application.
The call works fine using Visual Studio 2010 (typically), but the individual process falls over when the call is made on IIS6.
The only logs of any problems is an entry in Event Viewer:
Application: w3wp.exe
Framework Version: v4.0.30319
Description: The process was terminated due to stack overflow.
The Application Pool is running under the Network Service account, and this account has also been granted Modify access to the directory in question.
The 3rd Party confirmed that the problem was due to a problem in their memory allocation. The amount allocated on the stack not being sufficient.
The dll was suffering a stack overflow as a result and brought down w3wp.exe temporarily while IIS brought another process back up automatically.

wcf 4.0 service on IIS7

I am currently developing a service with wcf 4.0 (visual studio 2010 RC).
When I try my service on the Visual Studio Development Server, it all works perfect.
However, when I tree to run my service on IIS7 on a windows 7 machine, the service doesn't work anymore. (I already changed the framework version on my application pool).
When I call an operation on the service, like the default operation GetData when I create a service, I get an error.
I used the WCF test client to connect to the service.
When I call the operation on the service, the Visual Studio Just-In-Time debugger shows the following message:
An unhandled win32 exception occured in w3wp.exe
The Just-In-Time debugger was launched without necessary security permissions. To debug this proces, the JIT debugger must be run as an administrator. Would you like to debug the proces?
As far as I know, I am running Visual Studio as an administrator and this is probably the process that starts the JIT debugger.
The only option I have is to debug the W3WP process, which is probably not the right thing to do.
What can I do the make the Service to run on IIS7?
I already solved my problem, it was the ApplicationPoolIdentity that was blocking everything.

Resources