WebMethod中的例外

时间:2017-10-19 01:46:25

标签: c# webmethod

我的问题是关于网络服务

    [WebMethod]
    public string HelloWorld(bool Done)
    {


       return "";

    }

当我点击Invoke按钮时,给出空白值我们得到一个Exception,有没有办法处理这个,并给出一个信息性的消息

System.ArgumentException: Cannot convert  to System.Boolean.
Parameter name: type ---> System.FormatException: String was not recognized as a valid Boolean.
at System.Boolean.Parse(String value)
at System.String.System.IConvertible.ToBoolean(IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Web.Services.Protocols.ScalarFormatter.FromString(String value, Type type)
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.ScalarFormatter.FromString(String value, Type type)
at System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection)
at System.Web.Services.Protocols.HtmlFormParameterReader.Read(HttpRequest request)
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest 

我甚至试过它

public string HelloWorld(bool Done=false)

0 个答案:

没有答案