Mono ASP.NET Web服务中的System.ArgumentNullException

时间:2015-11-21 21:13:35

标签: asp.net web-services exception mono argumentnullexception

我是初学者,我不知道在哪里看或做什么。 请指导我完成这个。

我在ubuntu 14.04中使用mono v4.2.1和apache2

我设法在网址http://myurl/WebService/Service.asmx

中安装我的ASP.NET网络服务

但是当我打开它时,我收到了这个错误:

System.ArgumentNullException
Value cannot be null.
Parameter name: path1

Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): mscorlib.
Exception stack trace:
  at System.IO.Path.Combine (System.String path1, System.String path2) <0x40960a80 + 0x00211> in <filename unknown>:0 
  at System.Web.Services.Configuration.WsdlHelpGeneratorElement.get_HelpGeneratorPath () <0x40adbfb0 + 0x0003b> in <filename unknown>:0 
  at System.Web.Services.Protocols.DocumentationServerProtocol.Initialize () <0x40a73d70 + 0x00728> in <filename unknown>:0 
  at System.Web.Services.Protocols.ServerProtocol.SetContext (System.Type type, System.Web.HttpContext context, System.Web.HttpRequest request, System.Web.HttpResponse response) <0x40a72740 + 0x00103> in <filename unknown>:0 
  at System.Web.Services.Protocols.ServerProtocolFactory.Create (System.Type type, System.Web.HttpContext context, System.Web.HttpRequest request, System.Web.HttpResponse response, System.Boolean& abortProcessing) <0x40a72300 + 0x000c2> in <filename unknown>:0 

这是我的Service.asmx:

<%@ WebService Language="C#" CodeBehind="Service.asmx.cs" Class="ACE.Service" %>

Service.asmx.cs文件:

using System.Web.Services;

namespace ACE
{
    [WebService(Namespace = "http://myurl/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    public class Service : System.Web.Services.WebService
    {
        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }
    }
}

首先,它在 Microsoft Visual Studio 中完全正常,但是mono有这个问题。

第二点是,http://myurl/WebService/Service.asmx?wsdl以xml格式打开,但当我在 Microsoft Visual Studio 中将其添加为服务引用时,它会在此行引发异常:

ServiceSoapClient a = new ServiceSoapClient();

例外:

An unhandled exception of type 'System.InvalidOperationException' occurred in System.ServiceModel.dll
Additional information: An endpoint configuration section for contract 'ServiceReference1.ServiceSoap' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name.

但是,当我在 Microsoft Visual Studio 调试模式下部署我的Web服务时,它不会抛出此异常,但单声道会抛出它。

1 个答案:

答案 0 :(得分:0)

我发现这是因为单声道的版本。

我删除了官方单声道存储库的所有组件并安装了ubuntu mono-complete 软件包,并且已修复。