[英]Can I force svcutil.exe to generate data contracts for a WCF service?
I would like to force svcutil
to generate all data contracts in an assembly that is used by WCF, regardless of whether or not a type is referenced by a given operation contract. 我想强制svcutil
在WCF使用的程序集中生成所有数据协定,无论某个类型是否由给定的操作契约引用。
[DataContract]
public class Foo { }
[DataContract]
public class Bar : Foo { }
[ServiceContract]
public interface IService
{
[OperationContract]
void Get(Foo foo);
}
Given this setup I cannot get svcutil
to generate a version of Bar
as there are no operation contracts that currently reference it. 鉴于此设置,我无法获得svcutil
生成Bar
的版本,因为目前没有操作合同引用它。 Is there a way to force svcutil
to generate the data contract for Bar
? 有没有办法强制svcutil
为Bar
生成数据合约?
Add a KnownType attribute to the Foo class 将KnownType属性添加到Foo类
[KnownType(typeof(Bar))]
[DataContract]
public class Foo { }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.