的ServiceHost的定制工厂不能从GAC
装载我在IIS托管的WCF服务和服务工作正常。实际上它是按顺序使用以下Global.asax和OrderService.svc文件。的ServiceHost的定制工厂不能从GAC
<%@ 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"%>
我正在尝试制作一个\ bin \'较少的WCF服务并将其托管在IIS中。我将所有必要的程序集放入GAC。当我提出请求到服务,我得到以下错误:
<%@ Application Codebehind="Global.asax.cs" Inherits="MyCompany.MyOrderServices.Global, MyCompany.MyOrderServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=XXXXXXXXXXX" Language="C#" %>
所以我就点:
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
嗯,我通过改变在Global.asax如下文件修复了这个错误我必须将简单类型名称更改为类型的程序集限定名称。事实上,在我修复Global.asax错误之后,我得到以下错误。
Could not load file or assembly 'MyCompany.ServiceLibrary' or one of its dependencies. The system cannot find the file specified.
然后我启用了融合记录,得到了以下信息:
=== 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.
显然GAC文件夹被遗漏。然后我改变了如下所示的.svc文件:
<%@ 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"%>
......但我得到了同样的错误。 ServiceHost指令有什么问题。为什么不能从GAC文件夹加载程序集?
(注:顺便说一句,我查了以下链接建议改变简单的类型名称为大会限定的类型名称,但它没有为我工作
哈!
貌似我忘了编辑的Web.config:它也包含组件的名称。
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="CORSEnablingModule" type="MyCompany.ServiceLibrary.Cors.CORSEnablingModule, MyCompany.ServiceLibrary" />
</modules>
</system.webServer>
现在,我已经将其更改为完全限定的名称,一切都很好。
无论如何。
是的,但是您对web.config的编辑有助于从GAC正确加载汇编,请更新。这就是为什么有一个关于控制台的建议,因为它没有Web.Config。 –
您是否在GAC中手动检查了包含名称,版本,强名称和区域性的程序集,因为如果出现不匹配,它将不会加载程序集 –
是@ mrinal-kamboj我检查了GAC的程序集,它只是在那里:) – rebulanyum
你可以尝试与控制台应用程序相同的回购,一切都保持不变,从GAC加载,我只是想缩小到环境中的实际问题。请确保系统(PATH)中没有其他任何副本加载 –