Charles Baldo
asked on
C# Webservices Enum default value overide ignored
Hello I have the following enum in a class that is used in a web service
public enum Genders
{
Male = 1,
Female = 2
}
When I reference the webservice in a c# winform I get an error if I instantiate a class that is referenced to that web sevice
profile p = new profile();
p.Gender = (Genders)2;
When I run the code I get "There was an error generating the XML document." the stack trace goes back to the Reference.cs file. Sure enough in the reference I have code that looks like this
[System.CodeDom.Compiler.G eneratedCo deAttribut e("System. Xml", "2.0.50727.1433")]
[System.SerializableAttrib ute()]
[System.Xml.Serialization. XmlTypeAtt ribute(Nam espace="http://xxxxxxxx.net/") ]
public enum Genders {
/// <remarks/>
Male,
/// <remarks/>
Female,
}
So it is being cause by the local reference reseting the default back to 0 when it generates. If I go in and manually change the code in the reference.cs to
public enum Genders {
/// <remarks/>
Male=1,
/// <remarks/>
Female=2,
}
it works. However i can not do that because when it autogenerates it wipes my changes out as soon as I update the web reference.
Any Ideas why this is happening and what I can do to fix it?
public enum Genders
{
Male = 1,
Female = 2
}
When I reference the webservice in a c# winform I get an error if I instantiate a class that is referenced to that web sevice
profile p = new profile();
p.Gender = (Genders)2;
When I run the code I get "There was an error generating the XML document." the stack trace goes back to the Reference.cs file. Sure enough in the reference I have code that looks like this
[System.CodeDom.Compiler.G
[System.SerializableAttrib
[System.Xml.Serialization.
public enum Genders {
/// <remarks/>
Male,
/// <remarks/>
Female,
}
So it is being cause by the local reference reseting the default back to 0 when it generates. If I go in and manually change the code in the reference.cs to
public enum Genders {
/// <remarks/>
Male=1,
/// <remarks/>
Female=2,
}
it works. However i can not do that because when it autogenerates it wipes my changes out as soon as I update the web reference.
Any Ideas why this is happening and what I can do to fix it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER