当前位置: 首页 > news >正文

常德网站公司/百度一下你就知道官网

常德网站公司,百度一下你就知道官网,如何做情趣网站,国外经典logo设计案例分析作者:jiankunking 出处:http://blog.csdn.net/jiankunking 在项目中用到WCF,项目的结构是这样的: 在SPI项目中编写该解决方案中公共的类及函数; 在WCFService项目中写的是svc文件及WCF服务接口; 在Client中添加WCF服务…

作者:jiankunking 出处:http://blog.csdn.net/jiankunking

在项目中用到WCF,项目的结构是这样的:


在SPI项目中编写该解决方案中公共的类及函数;
在WCFService项目中写的是svc文件及WCF服务接口;
在Client中添加WCF服务引用的时候该WCFService项目,然后再UI项目中初始化Client的实例。通过该实例WCFService中的方法。
问题:

有时会出现这么一种情况,在UI中通过初始化Client的实例。通过该实例WCFService中的方法MethodA,该方法的入参是SPI中类ConnectionInfo的实例,然后在UI中再次使用类ConnectionInfo时会发现ConnectionInfo是在Client命名空间下的类,而不是在SPI命名空间下的类。

在WCF自动生成的客户端代理类(Reference.cs文件)中,会将SPI中的类ConnectionInfo,序列化成:

   

 [System.Diagnostics.DebuggerStepThroughAttribute()][System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")][System.Runtime.Serialization.DataContractAttribute(Name="ConnectionInfo", Namespace="http://schemas.datacontract.org/2004/07/HaiChuang.AMAC.DataSourceSettings.SPI.Mod" +"el")][System.SerializableAttribute()]public partial class ConnectionInfo : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {[System.NonSerializedAttribute()]private System.Runtime.Serialization.ExtensionDataObject extensionDataField;[System.Runtime.Serialization.OptionalFieldAttribute()]private string ConnectionStringField;[System.Runtime.Serialization.OptionalFieldAttribute()]private string GuidField;[System.Runtime.Serialization.OptionalFieldAttribute()]private string LocationField;[System.Runtime.Serialization.OptionalFieldAttribute()]private string MenuGuidField;[System.Runtime.Serialization.OptionalFieldAttribute()]private string NameField;[System.Runtime.Serialization.OptionalFieldAttribute()]private string TypeField;[System.Runtime.Serialization.OptionalFieldAttribute()]private int idField;[global::System.ComponentModel.BrowsableAttribute(false)]public System.Runtime.Serialization.ExtensionDataObject ExtensionData {get {return this.extensionDataField;}set {this.extensionDataField = value;}}[System.Runtime.Serialization.DataMemberAttribute()]public string ConnectionString {get {return this.ConnectionStringField;}set {if ((object.ReferenceEquals(this.ConnectionStringField, value) != true)) {this.ConnectionStringField = value;this.RaisePropertyChanged("ConnectionString");}}}[System.Runtime.Serialization.DataMemberAttribute()]public string Guid {get {return this.GuidField;}set {if ((object.ReferenceEquals(this.GuidField, value) != true)) {this.GuidField = value;this.RaisePropertyChanged("Guid");}}}[System.Runtime.Serialization.DataMemberAttribute()]public string Location {get {return this.LocationField;}set {if ((object.ReferenceEquals(this.LocationField, value) != true)) {this.LocationField = value;this.RaisePropertyChanged("Location");}}}[System.Runtime.Serialization.DataMemberAttribute()]public string MenuGuid {get {return this.MenuGuidField;}set {if ((object.ReferenceEquals(this.MenuGuidField, value) != true)) {this.MenuGuidField = value;this.RaisePropertyChanged("MenuGuid");}}}[System.Runtime.Serialization.DataMemberAttribute()]public string Name {get {return this.NameField;}set {if ((object.ReferenceEquals(this.NameField, value) != true)) {this.NameField = value;this.RaisePropertyChanged("Name");}}}[System.Runtime.Serialization.DataMemberAttribute()]public string Type {get {return this.TypeField;}set {if ((object.ReferenceEquals(this.TypeField, value) != true)) {this.TypeField = value;this.RaisePropertyChanged("Type");}}}[System.Runtime.Serialization.DataMemberAttribute()]public int id {get {return this.idField;}set {if ((this.idField.Equals(value) != true)) {this.idField = value;this.RaisePropertyChanged("id");}}}public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;protected void RaisePropertyChanged(string propertyName) {System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;if ((propertyChanged != null)) {propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));}}}
该实体类代码为:

/// <summary>/// 数据源信息/// </summary>public class ConnectionInfo{public int id { get; set; }public string Guid { get; set; }public string Name { get; set; }public string Location { get; set; }public string Type { get; set; }public string ConnectionString { get; set; }public string MenuGuid { get; set; }}

在 CLient项目的wcf引用上右键,可以看到该实体类


在项目中可以找到该dll


打开该dll,可以看到该类的信息


此处看到的类信息是被转成WCF数据契约形式的类信息


解决方案:

  如果要在UI项目中使用SPI命名空间下的类ConnectionInfo,则将Reference.cs文件中的public partial class ConnectionInfo删除,再在UI中引用SPI项目即可。

小注:

如果不进行修改,则在客户端调用WCF服务端方法的时候,获取函数入参类型或者返回值类型的类型(如果该入参、返回值 类型为自定义实体类),是通过WCF服务端获取的,即使该实体类在SPI中,客户端也有,调用的也是服务端的。

就相当于你自己显式将该自定义实体类标记为数据契约。

使用WebService也会出现这种问题,解决思路一样。
但产生这个问题的原因暂时还没有找到,因为UI项目中已经引用SPI项目了,还是会在Reference.cs文件中生成ConnectionInfo类的相关信息。希望知道原因的朋友留言说一下,谢谢。

http://www.lbrq.cn/news/969949.html

相关文章:

  • 一个人只做网站的流程/最近七天的新闻重点
  • 扬中市新闻网站/seo软件优化工具软件
  • 设计网站页面的作文/seo站内优化包括
  • 龙岩app定制/seo托管公司
  • 唐河做网站/seo视频教程汇总
  • 做的比较好的购物网站/百度开户需要什么资质
  • 学校门户网站建设的优势/网络推广引流是做什么工作
  • wordpress博客自媒体资讯主题/武汉seo和网络推广
  • 哪些网站做平面单页好看/搜索引擎公司排名
  • 中城投建设集团网站/手机网站seo免费软件
  • 服装商城的网站建设/网站关键词排名
  • 河南免费网站建设公司/百度一下你就知道下
  • 用手机制作动画的app/系统优化方法
  • wordpress插件webGL/seo关键词报价查询
  • 可以自己做装修效果图的网站/集合竞价口诀背熟6句
  • 中国物流网站/树枝seo
  • 网站设置在哪里找到/推广app是什么工作
  • 做门户网站的网络公司/天津放心站内优化seo
  • 网站制作的地方/百度建站多少钱
  • 团队网站怎么做/精准营销平台
  • 绥化市建设局网站/朔州网站seo
  • 网站第三方微信登陆怎么做的/安徽网络建站
  • 公司网站建设 阜阳/网站seo具体怎么做?
  • 网站建设和seo讲师要求/百度风云榜电视剧排行榜
  • 做网站放什么/地方网站建设
  • 哪些网站可以接工程做/seo搜索引擎优化知乎
  • WordPress的/seo接单
  • 网站建设公司上海做网站公司排名/网址域名注册信息查询
  • 最专业网站建设公司哪家好/爱站网长尾挖掘工具
  • dreamweaver制作网站教程/seo基础知识
  • 工作第一步建立连接——ssh
  • uniapp写好的弹窗组件
  • 【人工智能99问】神经网络的工作原理是什么?(4/99)
  • 读取ubuntu的磁盘分区表与超级块
  • OSPFv3中LSA参数
  • 全面安装指南:在Linux、Windows和macOS上部署Apache Cassandra