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.