我将此数据协定类作为我的WCF服务器代码中的单独dll:
namespace Engine.V100.SharedDataContract
{
#region Authorization
[DataContract(Namespace = "Engine.V100.SharedDataContract")]
[Serializable]
public class Identity
{
[DataMember]
public string UserName;
[DataMember]
public Guid UserID;
[DataMember]
public string PassWord;
[DataMember]
public Guid GroupCode;
}
#endregion
}
我在客户端代码中引用了相同的dll,并选择了“在所有引用的程序集中重用类型”选项。但是,类型Identity仍然是由每个服务引用单独定义的,我有组件冲突的问题。
这是客户端服务引用生成的示例:
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="Identity", Namespace="http://tempuri.org/")]
[System.SerializableAttribute()]
public partial class Identity : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {
[System.NonSerializedAttribute()]
private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private string UserNameField;
private System.Guid UserIDField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private string PassWordField;
private System.Guid GroupCodeField;
[global::System.ComponentModel.BrowsableAttribute(false)]
public System.Runtime.Serialization.ExtensionDataObject ExtensionData {
get {
return this.extensionDataField;
}
set {
this.extensionDataField = value;
}
}
[System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false)]
public string UserName {
get {
return this.UserNameField;
}
set {
if ((object.ReferenceEquals(this.UserNameField, value) != true)) {
this.UserNameField = value;
this.RaisePropertyChanged("UserName");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute(IsRequired=true, Order=1)]
public System.Guid UserID {
get {
return this.UserIDField;
}
set {
if ((this.UserIDField.Equals(value) != true)) {
this.UserIDField = value;
this.RaisePropertyChanged("UserID");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=2)]
public string PassWord {
get {
return this.PassWordField;
}
set {
if ((object.ReferenceEquals(this.PassWordField, value) != true)) {
this.PassWordField = value;
this.RaisePropertyChanged("PassWord");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute(IsRequired=true, Order=3)]
public System.Guid GroupCode {
get {
return this.GroupCodeField;
}
set {
if ((this.GroupCodeField.Equals(value) != true)) {
this.GroupCodeField = value;
this.RaisePropertyChanged("GroupCode");
}
}
}
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));
}
}
}
referened type namespace是tempuri可能相当可观。 请帮忙