ERROR: Proxy already has a definition for enum

Topics: Service Factory Modeling Edition Forum
Mar 20, 2008 at 5:02 PM
Edited Mar 26, 2008 at 9:47 PM
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", "")
System.Runtime.Serialization.DataContractAttribute(Name = "SystemMessage", Namespace = "urn:XXX.XXX.ServiceContracts")
public enum MyEnum : int

EmailAddressNotFound = 0,

UnknownError = 1,

Success = 2,

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

/// <remarks/>

/// <remarks/>

Any help is greatly appreciated.


Mar 21, 2008 at 8: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.