简体   繁体   English

在IIS中的另一个站点中引用Web Service时失败

[英]Web Service fails when referencing it in another site in IIS

I've got a C# 3.5 web service that works fine when its accessed at http://domain/foo/bar/WS.asmx 我有一个C#3.5 Web服务,当通过http://domain/foo/bar/WS.asmx访问该服务时,它可以正常工作

The /foo/bar part could change in the future so I want to give people a more stable URL that I could update without requiring any changes from them. / foo / bar部分将来可能会更改,因此我想为人们提供一个更稳定的URL,可以更新该URL,而无需他们进行任何更改。 I created a site in IIS and set it's Home Directory to where WS.asmx is. 我在IIS中创建了一个站点,并将其主目录设置为WS.asmx所在的位置。 Now when I try to access it from http://domain2/WS.asmx , I get: 现在,当我尝试从http://domain2/WS.asmx访问它时,我得到:

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 create type 'Namespace.WS'. 解析器错误消息:无法创建类型'Namespace.WS'。

Source Error: Line 1: <%@ WebService Language="C#" CodeBehind="WS.asmx.cs" Class="Namespace.WS" %> 源错误:第1行:<%@ Web服务语言=“ C#” CodeBehind =“ WS.asmx.cs” Class =“ Namespace.WS”%>

The assemblies in both cases are at http://domain/bin but when I come from domain2 it doesn't seem to know where to find the \\bin that is 3 folders up in the file system. 两种情况下的程序集都位于http:// domain / bin,但是当我来自domain2时,它似乎不知道在哪里可以找到文件系统中3个文件夹的\\ bin。

The namespace/classes are more descriptive than that, I just made them basic for the purposes of this question. 命名空间/类比这更具描述性,出于这个问题的目的,我只是将它们设为基本。

Sorry, AFAIK you can't pull DLLs from explicit file paths outside the root of your website. 抱歉,AFAIK无法从网站根目录之外的显式文件路径中提取DLL。 You generally have two choices: 1) use the /bin directory of the current app (make a copy of the other app's /bin) 2) put the DLL into the Global Assembly Cache (GAC) 通常,您有两种选择:1)使用当前应用程序的/ bin目录(制作另一个应用程序的/ bin的副本)2)将DLL放入全局程序集缓存(GAC)

BTW, this has been asked in a few other spots on SO, like here . 顺便说一句,已经在SO的其他几个地方(例如此处)提出了这个问题

One thing you could do, if your /bin DLLs are only used inside /foo/bar/, is to convert into an IIS application, and then move the DLLs into a new /foo/bar/bin directory. 如果/ bin DLL仅在/ foo / bar /内部使用,您可以做的一件事就是将其转换为IIS应用程序,然后将DLL移至新的/ foo / bar / bin目录中。 Then you'd only have one copy of the DLL's to manage. 这样一来,您只需要管理DLL的一个副本即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM