C# 在IIS 7.0中托管Web服务(非WCF)

C# 在IIS 7.0中托管Web服务(非WCF),c#,web-services,iis-7,C#,Web Services,Iis 7,我已经用C#编写了一个Web服务,并试图在IIS 7.0上托管它。考虑下面的代码,这个代码运行良好,可以托管在IIS 7上,没有问题: using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Web; using System.Web.Services; using VMware; namespace vmareSe

我已经用C#编写了一个Web服务,并试图在IIS 7.0上托管它。考虑下面的代码,这个代码运行良好,可以托管在IIS 7上,没有问题:

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Web.Services;
using VMware;

namespace vmareService
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the     following line. 
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{

    [WebMethod]

    public void logintoVmware(string URL, string username, string password)
          {
        VMware.Vim.VimClient client = new VMware.Vim.VimClient();

    }

}
}
任何帮助都将不胜感激

谢谢

从评论中粘贴:


您应该确保此文件位于/bin文件夹中。如果是,那么您应该调查它的潜在依赖关系可能是什么。请记住,此文件存在并不意味着其所有从属DLL都可用。

您应该确保此文件位于/bin文件夹中。如果是,那么您应该调查它的潜在依赖关系可能是什么。记住,仅仅因为这个文件存在并不意味着它的所有依赖DLL都可用。嗨,乔,天知道这个论坛救了我多少次命。你是个天才,我真的很想为此感谢你。这解决了你的问题吗?如果是这样,我会把它作为一个可行的答案发布。还有一件事正在发生,,,现在我可以在IIS上托管该服务,但是当尝试使用该Web服务时,我会出错。我通过VS2010托管webservice并运行另一个VS2010实例来调用它,从而测试了webservice。它在VS中工作正常,但在IIS上托管时,它开始请求DLL和程序集,否则它不会请求。。。VS2010托管和IIS托管之间有什么区别吗?嗨,Joel,是的,这确实解决了我的问题。现在我可以主持了,没问题。但是在IIS上调用它公开的方法是不起作用的。我该怎么做才能让它工作?为什么我能够在VS2010中调用该方法,但在IIS 7中无法调用该方法呢?所有这些都很好,问题在于c:\windir\assembly中缺少程序集。如果您说明缺少哪个程序集,这样的注释对其他读者会更有帮助。。
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Web.Services;
using VMware;

namespace vmareService
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the     following line. 
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{

    [WebMethod]

    //public void logintoVmware(string URL, string username, string password)
    public VMware.Vim.UserSession logintoVmware(string URL, string username, string password)
    {
        VMware.Vim.VimClient client = new VMware.Vim.VimClient();
        VMware.Vim.UserSession session;
        session = client.Login(URL, username, password);
        return session;

    }

}
}
Server Error in '/vmService' Application.

Could not load file or assembly 'VMware.Vim, Version=5.0.0.0, Culture=neutral,     PublicKeyToken=10980b081e887e9f' or one of its dependencies. The system cannot find the file  specified.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'VMware.Vim, Version=5.0.0.0, Culture=neutral, PublicKeyToken=10980b081e887e9f' or one of its dependencies. The system cannot find the file specified.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'VMware.Vim, Version=5.0.0.0, Culture=neutral, PublicKeyToken=10980b081e887e9f' could not be loaded.


WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value   [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value    [HKLM\Software\Microsoft\Fusion!EnableLog].

Stack Trace: 


[FileNotFoundException: Could not load file or assembly 'VMware.Vim, Version=5.0.0.0,      Culture=neutral, PublicKeyToken=10980b081e887e9f' or one of its dependencies. The system cannot find the file specified.]
System.Signature._GetSignature(SignatureStruct& signature, Void* pCorSig, Int32 cCorSig, IntPtr fieldHandle, IntPtr methodHandle, IntPtr declaringTypeHandle) +0
 System.Signature..ctor(RuntimeMethodHandle methodHandle, RuntimeTypeHandle declaringTypeHandle) +236
System.Reflection.RuntimeMethodInfo.get_Signature() +91
System.Reflection.RuntimeMethodInfo.get_ReturnType() +19
System.Reflection.RuntimeMethodInfo.ToString() +36
System.Web.Services.WebMethodReflector.GetMethods(Type type) +255
System.Web.Services.Description.ServiceDescriptionReflector.Reflect(Type type, String  url) +77
System.Web.Services.Protocols.DocumentationServerType..ctor(Type type, String uri) +203
System.Web.Services.Protocols.DocumentationServerProtocol.Initialize() +388
System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context,  HttpRequest request, HttpResponse response) +75
System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing) +143

[InvalidOperationException: Unable to handle request.]
System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext  context, HttpRequest request, HttpResponse response, Boolean& abortProcessing) +458971
System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type,   HttpContext context, HttpRequest request, HttpResponse response) +285

[InvalidOperationException: Failed to handle request.]
System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +401754
System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +281
System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +89
 System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute () +425
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&  completedSynchronously) +263

Version Information: Microsoft .NET Framework Version:2.0.50727.5456; ASP.NET      Version:2.0.50727.5456