【问题标题】:How to reference a custom DLL from an uncompiled .NET webservice如何从未编译的 .NET Web 服务中引用自定义 DLL
【发布时间】:2012-06-06 17:16:21
【问题描述】:

由于各种原因,我不会深入探讨我需要在 Visual Studio 之外编写我的 .NET Web 服务。这本身并不困难,以下工作正常......

<%@ WebService Language="C#" Class="TestHW" %>

using System;
using System.Web.Services;
using System.Xml.Serialization

[WebService(Namespace="http://www.mydomain.com/services")]
public class TestHW : WebService {
    [WebMethod()]
    public string Add(int a, int b) {
        return a + b;
    }
}

我需要从此 Web 服务引用自定义 .NET DLL,但我无法通过 .asmx 找到 DLL(位于同一目录中)。谷歌很困难,因为每个人显然都想从 DLL 中引用 Web 服务,而不是反过来。一切都以 .NET 2.0 为目标。

using websvc; //DLL is websvc.dll with namespace websvc

给出错误...

CS0246: The type or namespace name 'websvc' could not be found (are you missing a using directive or an assembly reference?)

感谢您的宝贵时间。

【问题讨论】:

    标签: .net web-services dll


    【解决方案1】:

    终于在How do I reference a component in an inline web service?找到了

    <%@ Assembly Name="MyAssembly" %>
    

    <%@ Assembly Src="path/myFile.cs" %>
    

    名称语法用于已编译的 DLL,src 语法用于开放代码。 dll似乎需要在根目录下的bin目录中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-10
      • 2011-10-15
      • 1970-01-01
      • 2010-12-17
      • 2018-02-09
      • 2023-03-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多