One of the teams I am working with ran into an issue when generating shared types via SvcUtil. The issue was SvcUtil was generating multiple types (e.g., classes, enums) in the proxy .cs file. After a google search, I found this was being experienced by others:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=745657&SiteID=1
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1392697&SiteID=1
An example of the duplicate types:
|
[System.CodeDom.Compiler.
GeneratedCodeAttribute("svcutil", "3.0.3906.22")]
[System.
SerializableAttribute()]
[System.Xml.Serialization.
XmlTypeAttribute(Namespace="http://schemas.datacontract.org/2004/07/LR.Model.Enums")]
public enum ReturnStatusEnum
{
/// <remarks/>
None,
/// <remarks/>
BadLogonOrPassword,
/// <remarks/>
Successful,
}
[System.CodeDom.Compiler.
GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
[System.Runtime.Serialization.
DataContractAttribute(Namespace="http://schemas.datacontract.org/2004/07/LR.Model.Enums")]
public enum ReturnStatusEnum : int
{
[System.Runtime.Serialization.
EnumMemberAttribute()]
None = -1,
[System.Runtime.Serialization.
EnumMemberAttribute()]
BadLogonOrPassword = 0,
[System.Runtime.Serialization.
EnumMemberAttribute()]
Successful = 1,
}
|
|
|
|
|
|
The solution is simply including a switch to SvcUtil to force the serializer to be a specific type. The default is Auto so in the example above, the SvcUtil decided to use the XmlSerializer for one class and the DataContractSerializer for another.
An example of the syntax: svcutil /ns:*,my.namespace /serializer:XmlSerializer service1.svc service2.svc service3.asmx
Hope this saves someone some time!
Posted
Aug 01 2008, 06:07 AM
by
chilberto