apache asp.net on mono:如何添加对程序集的引用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1239395/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 18:02:25  来源:igfitidea点击:

asp.net on mono: how to add a reference to an assembly

c#asp.netapachemono

提问by bernhardrusch

Very basic question - but I couldn't find an answer. I have got a asp.net web service which is located in an asmx file. This should call a function from a helper library. Using a different asmx file in Visual Studio everything is working fine - I just had to add the assembly to the dependencies of this project.

非常基本的问题 - 但我找不到答案。我有一个位于 asmx 文件中的 asp.net Web 服务。这应该从帮助程序库中调用一个函数。在 Visual Studio 中使用不同的 asmx 文件一切正常 - 我只需将程序集添加到该项目的依赖项中。

Altough I have copied the assembly to the bin subdirectory on the webserver (I think this was what the descriptions I've read said) it returns this error message:

尽管我已将程序集复制到网络服务器上的 bin 子目录(我认为这是我读过的描述),但它返回以下错误消息:

Server Error in '/' Application CS0246: The type or namespace name `XXXFunctions' could not be found. Are you missing a using directive or an assembly reference?

Description: HTTP 500. Error processing request.

Stack Trace:

System.Web.Compilation.CompilationException: CS0246: The type or namespace name XXXFunctions' could not be found. Are you missing a using directive or an assembly reference? at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x00000] at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Collections.Generic.List1 buildItems, System.Web.VirtualPath virtualPath, BuildKind buildKind) [0x00000] at System.Web.Compilation.BuildManager.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) [0x00000] at System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler (System.Web.HttpContext context, System.String verb, System.String url, System.String filePath) [0x00000]
at System.Web.Script.Services.ScriptHandlerFactory.GetHandler (System.Web.HttpContext context, System.String requestType, System.String url, System.String pathTranslated) [0x00000] at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url, Boolean ignoreContextHandler) [0x00000] at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url) [0x00000] at System.Web.HttpApplication+c__Iterator2.MoveNext () [0x00000]

“/”应用程序 CS0246 中的服务器错误:找不到类型或命名空间名称“XXXFunctions”。您是否缺少 using 指令或程序集引用?

描述:HTTP 500。处理请求时出错。

堆栈跟踪:

System.Web.Compilation.CompilationException: CS0246: 类型或命名空间名称 XXXFunctions' could not be found. Are you missing a using directive or an assembly reference? at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x00000] at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Collections.Generic.List1 buildItems, System.Web.VirtualPath virtualPath, BuildKind buildKind) [0x00000] 在 System.Web.Compilation.BuildManager.BuildAssembly (System.Web.VirtualPath virtualPath) [ 0x00000] 在 System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) [0x00000] 在 System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(System.Web.HttpContext 上下文,System.String 动词,System.String url , System.String filePath) [0x00000]
在 System.Web.Script.Services.ScriptHandlerFactory.GetHandler (System.Web.HttpContext context, System.String requestType, System.String url, System.String pathTranslated) [0x00000] 在 System.Web.HttpApplication.GetHandler (System.Web .HttpContext context, System.String url, Boolean ignoreContextHandler) [0x00000] at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url) [0x00000] at System.Web.HttpApplication+c__Iterator2.MoveNext ( ) [0x00000]

This is the asmx file I'm using:

这是我正在使用的 asmx 文件:

<%@ Assembly name="System.Web.Extensions" %>
<%@ Assembly name="System.Runtime.Serialization" %>
<%@ Assembly name="System.ServiceModel.Web" %>
<%@ WebService Language="C#" Class="FCWService.FCWService" %>

using System;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.IO;
using System.Text;

namespace FCWService
{
    [WebService (Namespace = "http://tempuri.org/NumberService")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ScriptService]
    public class FCWService : System.Web.Services.WebService
    {
        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public XXXFunctions.Data GetData(double length)
        {
            return XXXFunctions.Functions.GetData(length);
        }
    }
}

Any ideas ?

有任何想法吗 ?



回答:我发现 asmx 页面顶部缺少 <%@ Assembly name="XXXFunctions" %> 指令。

回答by supercheetah

Are you sure you copied everything you needed? There seems to be a namespace or something called XXXFunctions that's missing on the server.

你确定你复制了你需要的一切吗?服务器上似乎缺少命名空间或称为 XXXFunctions 的东西。

回答by bernhardrusch

Answered: I found out that there was a <%@ Assembly name="XXXFunctions" %> directive was missing on top the asmx page.

回答:我发现 asmx 页面顶部缺少 <%@ Assembly name="XXXFunctions" %> 指令。