C# webservice调用中出错

C# webservice调用中出错,c#,asp.net,web-services,soap,asmx,C#,Asp.net,Web Services,Soap,Asmx,我试图在两个网站之间创建一个Web服务,但当我调用它时,我得到以下错误: System.Web.Services.Protocols.SoapException:System.Web.Services.Protocols.SoapException:服务器无法处理请求。-->System.Collections.Generic.KeyNotFoundException:字典中不存在给定的键。 在CreateAttendee..ctor()上 ---内部异常堆栈跟踪的结束--- en System

我试图在两个网站之间创建一个Web服务,但当我调用它时,我得到以下错误:

System.Web.Services.Protocols.SoapException:System.Web.Services.Protocols.SoapException:服务器无法处理请求。-->System.Collections.Generic.KeyNotFoundException:字典中不存在给定的键。 在CreateAttendee..ctor()上 ---内部异常堆栈跟踪的结束--- en System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage消息、WebResponse响应、Stream responseStream、Boolean异步调用) en System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName,Object[]参数) 创建(字符串参数)en c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\godigix\0e20025a\e335649\App\u WebReferences.zfpla\u cn.0.cs:línea 46 en events_EstudiosShopper2015.RegisterAttendee(字符串名称、字符串电子邮件、布尔接受通知)en f:\SVN\goDigix\Web\www.goDigix.com\events\EstudiosShopper2015.aspx.cs:línea 106

我有以下代码来调用Web服务:

string dataToSend="name=myName&email=myemail@mydomain.com";
WSCreateAttendee.CreateAttendee webService = new CreateAttendee();
string webServiceResponse = webService.Create(dataToSend);
我的目的地有以下几点:

/// <summary>
/// Web service used to create a new company
/// </summary>
[WebService(Namespace = "http://glothos.sureact.com", Name="CreateAttendee")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

public class CreateAttendee : System.Web.Services.WebService
{
    public CreateAttendee()
    {
        //do nothing
    }
    [WebMethod]
    public string Create(string parameters)
    {
        //Log into DB the name and email received
    }
}
//
///用于创建新公司的Web服务
/// 
[WebService(命名空间=”http://glothos.sureact.com“,Name=“CreateAttendee”)]
[WebServiceBinding(ConformsTo=WsiProfiles.BasicProfile1_1)]
公共类CreateAttendee:System.Web.Services.WebService
{
public CreateAttendee()
{
//无所事事
}
[网络方法]
公共字符串创建(字符串参数)
{
//将收到的姓名和电子邮件登录到DB
}
}
有人能帮我吗?我不知道我做错了什么


谢谢你

这个例外的关键是他在评论你的问题时说:

字典中不存在给定的键。在CreateAttendee..ctor()上

在尝试检索键标识对象之前,应确保在
CreateAttendee
类上使用的构造函数验证该对象是否存在

例如:

if (dictionary.ContainsKey("Id"))
{
    value = dictionary["Id"]
}
else
{
    // Act when the key does not exist...
}

一旦您向我们展示了一些代码,我们就可以帮助您在
CreateGlothosAttendee.CreateAttendee.CreateAttendee()
中引发异常,该异常会执行
new CreateAnteendee()
,您可以使用
字典[“key”]
,其中“key”不存在。您好,我已经在我的问题中添加了更多信息。但是我在我的Web服务中不使用任何“键”或“字典”,或者我不知道我正在使用它们。ASMX是一种遗留技术,不应用于新的开发。WCF或ASP.NET Web API应用于Web服务客户端和服务器的所有新开发。一个提示:微软已经在MSDN上退出了。