2
votes

I have a WCF service hosted in IIS and the service is working fine. Actually it's using the following Global.asax and OrderService.svc files in order.

<%@ Application Codebehind="Global.asax.cs" Inherits="MyCompany.MyOrderServices.Global" Language="C#" %>

<%@ ServiceHost Language="C#" Debug="true" Service="MyCompany.ServiceLibrary.OrderServiceImpl"   Factory="MyCompany.ServiceLibrary.GenericServiceHostFactoryImpl, MyCompany.ServiceLibrary"%>

I'm trying to make a \bin\ 'less WCF Service and host it in IIS. I put all the necessary assemblies into GAC. When I make request to the service I get the following error:

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load the assembly 'MyCompany.MyOrderServices'. Make sure that it is compiled before accessing the page.

Source File: /global.asax Line: 1

Well, I fixed this error by changing the Global.asax file as below:

<%@ Application Codebehind="Global.asax.cs" Inherits="MyCompany.MyOrderServices.Global, MyCompany.MyOrderServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=XXXXXXXXXXX" Language="C#" %>

So I got the point: I had to change simple type names into assembly qualified names of the types. Actually after I fixed the Global.asax error, then I get the following error.

Could not load file or assembly 'MyCompany.ServiceLibrary' or one of its dependencies. The system cannot find the file specified.

Then I enabled Fusion logging and got the information below:

=== Pre-bind state information ===

LOG: DisplayName = MyCompany.ServiceLibrary

(Partial)

WRN: Partial binding information was supplied for an assembly:

WRN: Assembly Name: MyCompany.ServiceLibrary | Domain ID: 4

WRN: A partial bind occurs when only part of the assembly display name is provided.

WRN: This might result in the binder loading an incorrect assembly.

WRN: It is recommended to provide a fully specified textual identity for the assembly,

WRN: that consists of the simple name, version, culture, and public key token.

WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.

LOG: Appbase = file:///C:/OrderServicePublish/

LOG: Initial PrivatePath = C:\OrderServicePublish\bin

Calling assembly : (Unknown).

===

LOG: This bind starts in default load context.

LOG: Using application configuration file: C:\OrderServicePublish\web.config

LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config

LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.

LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).

LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/98694738/2a3c07d8/MyCompany.MyServiceLibrary.DLL.

LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/98694738/2a3c07d8/MyCompany.MyServiceLibrary/MyCompany.MyServiceLibrary.DLL.

LOG: Attempting download of new URL file:///C:/OrderServicePublish/bin/MyCompany.MyServiceLibrary.DLL.

LOG: Attempting download of new URL file:///C:/OrderServicePublish/bin/MyCompany.MyServiceLibrary/MyCompany.MyServiceLibrary.DLL.

LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/98694738/2a3c07d8/MyCompany.MyServiceLibrary.EXE.

LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/98694738/2a3c07d8/MyCompany.MyServiceLibrary/MyCompany.MyServiceLibrary.EXE.

LOG: Attempting download of new URL file:///C:/OrderServicePublish/bin/MyCompany.MyServiceLibrary.EXE.

LOG: Attempting download of new URL file:///C:/OrderServicePublish/bin/MyCompany.MyServiceLibrary/MyCompany.MyServiceLibrary.EXE.

Apparently GAC folders are omited. Then I changed the .svc file like below:

<%@ ServiceHost Language="C#" Debug="true" Service="MyCompany.ServiceLibrary.OrderServiceImpl, MyCompany.ServiceLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=XXXXXXXXXXX"   Factory="MyCompany.ServiceLibrary.GenericServiceHostFactoryImpl, MyCompany.ServiceLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=XXXXXXXXXXX"%>

... But I'm getting the same error. What is the problem with ServiceHost directive. Why can't the assembly be loaded from GAC folders?

(note1: By the way; I checked the following links suggesting to change simple type names into Assembly qualified type names but It didn't worked for me.

1) https://social.msdn.microsoft.com/Forums/vstudio/en-US/3c61739c-b1fe-46bd-b8eb-8e9485f8891b/wcf-service-without-bin-folder?forum=wcf

2) http://answers.flyppdevportal.com/categories/sharepoint2010/sharepoint2010programming.aspx?ID=7b968dc5-4522-4896-8684-34064f0baaf5)

1
Did you manually checked the assembly with name, version, strong name and culture in the GAC, because if there's a mismatch it will not load the assemblyMrinal Kamboj
Yes @mrinal-kamboj I checked the GAC for the assembly and it's just there :)rebulanyum
Can you try the same repo with a Console application, everything remain same does it loads from GAC, I am just trying to narrow down to the actual issue in the environment. Please ensure there's no other copy in system (PATH) any where for it to loadMrinal Kamboj

1 Answers

0
votes

Hah!

Looks like I forgot to edit Web.config: it also contains assembly names.

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true">
    <add name="CORSEnablingModule" type="MyCompany.ServiceLibrary.Cors.CORSEnablingModule, MyCompany.ServiceLibrary" />
  </modules>
</system.webServer>

Now, I've changed it to fully qualified name and everything is fine.

Thanks anyway.