走投无路了,求救贴:C#根据WSDL生成代理类后,WSDL中的EXCEPTION无法解析

哈哈-_-123 2014-10-03 11:01:48
/// <remarks/>
[System.Xml.Serialization.XmlIncludeAttribute(typeof(CreditException))]
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://service.credit.nongxintong.com")]
public partial class Exception {

private object exception1Field;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Exception", IsNullable=true)]
public object Exception1 {
get {
return this.exception1Field;
}
set {
this.exception1Field = value;
}
}
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.1432")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://commons.nongxintong.com/xsd")]
public partial class CreditException : Exception {

private string messageField;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
public string message {
get {
return this.messageField;
}
set {
this.messageField = value;
}
}
}


提示错误:Error 1 The type 'Exception' already contains a definition for 'exception1Field' E:\vsworkspace\nongxintong_manager\nongxintong_manager\webservice\creditService.cs 538 20 nongxintong_manager
...全文
141 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
不是随便什么类型(父类)都可以用的,许多类型不能用。你必须自己定义一个Exception父类,例如写
namespace MyModels
    public class Exception
    {
        public string Message;
    }

.....
然后从你自己的 Exception 上继承。
rtdb 2014-10-03
  • 打赏
  • 举报
回复
Exception是C#关键字, 不能用于自定义的类名。 你手工换个名字试试。
哈哈-_-123 2014-10-03
  • 打赏
  • 举报
回复
恩,的确是因为类名有问题,不过这是用的VS的生成工具生成的,而给出的WSDL 文件 中已经有定义Exception了
puler 2014-10-03
  • 打赏
  • 举报
回复
没弄过,看看,接分

12,163

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧