Wednesday, December 15, 2010

WCF Hosting – Issues with VS2010 and Fresh IIS 6

I need to deploy a WCF web service to test environment. Web service is developed with VS2010 (.Net 4.0). When I prepared a build of 28 projects with single service using them. I just compiled and build the service with option ‘Any CPU’ and copy to test machine.

Test machine is Windows 2003 server x64 bit using IIS6. When I registered wcf service I figured out the ASP.Net is not registered with IIS.

Action: I run command >> aspnet_regiis –i
Next error appeared in browser was The Error 404 “Page not found” …..

On enquiry, I found that I should check the detailed sub option from log under 404. So I get to IIS->Web Sites->Propertie -> Log Properties and traced log file path. Then I opened log file where following last entry was there:

2010-12-14 04:03:30 W3SVC1 127.0.0.1 GET /GD.AutoDist.MainService/AutomatedService.svc – 80 – 127.0.0.1 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.2;+WOW64;+Trident/4.0;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.4506.2152;+
.NET+CLR+3.5.30729;+.NET4.0C;+.NET4.0E) 404 2 1260

What is 404.2. Here is a description:

404 – Page not found.

  • 404.0 – (None) – File or directory not found. ·
  • 404.1 – Web site not accessible on the requested port.
  • 404.2 – Web service extension lockdown policy prevents this request. ·
  • 404.3 – MIME map policy prevents this request.

So my issue is “Web service extension lockdown policy prevents this request.”. means my policy is preventing the ASP.NET 4.0 ISAPI extension from processing your request. It happened because check it out:


Starting from “0″ the last line means v4.0 aspnet_isapi.dll is disabled? There’s your problem. So to enable it I tried it:


Now when I tried to access WCF service I get following Error:

The type ‘xxxxxxxxx’ provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
And here is Exception details:

System.InvalidOperationException: The type ‘GD.AutoDist.MainService.AutomatedService’, provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
I googled the issue and found perhaps its good idea to add following line under services tab in web.config:

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled=”true” />
….

Next error was as follows:

Server Error in ‘/’ Application.
Parser Error Message: It is an error to use a section registered as allowDefinition=’MachineToApplication’ beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

Till now here is my IIS virtual directory settings: (Above error is saying I should create it as application)



When I created Application by clicking create button above, afterwards I get a new error:

Server Error in '/GD.AutoDist.MainService.AutomatedService' Application.
Could not load file or assembly 'GD.AutoDist.Server.Common' or one of its dependencies. An attempt was made to load a program with an incorrect format.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.


I did above thing in registry and now I can see the error log in detail on webpage. But other than that what does this means: one of the dll ‘GD.AutoDist.Server.Common’ in my solution is creating a problem. But what’s it. I rechecked the bin folder and common dll lonag with all its dependencies was there. Then I realized, its 64 bit operating system, why not to check the build option for common library in VS2010. And I figured out that its x86 instead of ‘Any CPU’. So I changed it rebuilt the dlls and placed in deployment folder. (I also ensured that all the dlls are using Framework 4.0) Finally the issues are over. Now I can start wcf service in browser



That’s it:)

1 comment: