ERROR: Proxy already has a definition for enum

Topics: Service Factory Modeling Edition Forum
Mar 20, 2008 at 6:02 PM
Edited Mar 26, 2008 at 10:47 PM
Hello:
I'm having a problem with my service. Both data contract enumeration shapes are giving me the following error: "The namespace 'xx.xx.xx.Svc.WCF.Client.XXProxy' already contains a definition for 'MyEnum'"; and "The namespace 'xx.xx.xx.Svc.WCF.Client.XXProxy' already contains a definition for 'MyEnum2'.

I had this all working until 2 days ago, when I accidentally deleted a enum shape representing "MyEnum". I replaced it with a new enum shape of the same name. From then on, I would get the above errors everytime i generate a new proxy through the host explorer. I've tried validating and regenerating code in different orders without luck.

Below are the 2 conflicting enums taken from my XXProxy.cs file:

First Block:
System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")
System.Runtime.Serialization.DataContractAttribute(Name = "SystemMessage", Namespace = "urn:XXX.XXX.ServiceContracts")
public enum MyEnum : int
{

System.Runtime.Serialization.EnumMemberAttribute()
EmailAddressNotFound = 0,

System.Runtime.Serialization.EnumMemberAttribute()
UnknownError = 1,

System.Runtime.Serialization.EnumMemberAttribute()
Success = 2,
}


Second Block:
/// <remarks/>
System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.1433")
System.SerializableAttribute()
System.Xml.Serialization.XmlTypeAttribute(Namespace = "urn:XXXX.XX.ServiceContracts")
public enum MyEnum
{
/// <remarks/>
EmailAddressNotFound,

/// <remarks/>
UnknownError,

/// <remarks/>
Success,
}

Any help is greatly appreciated.

Thanks,

Jeff
Mar 21, 2008 at 9:30 PM
I think i found the issue. When you Generate Code from your model, it doesn't delete any auto-generated .cs files from the Data Contracts project. So when I created my proxy, it was reading both old & new code.

Hope this saves someone some time.