c# - WCF:DataMember 的 "IsRequired"属性和 DataContract 的 "IsReference"属性

标签 c# .net wcf soap

当我为 DataMember 的 DataContract 设置“IsReference”属性时,为什么 WCF 不允许为 DataMembers 设置“IsRequired”属性?有没有办法解决这个问题?

    [DataContract(IsReference = true)]
    public class MyClass
    {
        private DateTime date;

        [DataMember (IsRequired = true)]
        public DateTime Date
        {
            get { return date; }
            set { date = value; }
        }
    }

此代码将产生错误,因为设置了“IsReference”和“IsRequired”。

最佳答案

您得到的行为有解释 here

我不确定如何解决这个问题

关于c# - WCF:DataMember 的 "IsRequired"属性和 DataContract 的 "IsReference"属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2176421/

相关文章:

c# - "The process cannot access the file X because it is used by another process"-C#

c# - 如何将枚举值传递给@Html.ActionLink

javascript - Angular Js web应用程序数据绑定(bind)无法从Sql数据库中捕获数据

c# - 从具有 FaultException 的 WCF Web 服务中消除天妇罗

wcf - 自托管 WCF 服务主机/WebServiceHost 并发/性能设计选项 (.NET 3.5)

c# - 在 bin 目录中找不到 AppConfig 文件

.net - 如何在 TreeView 外部绘制 TreeView 节点+/-按钮?

c# - 如何取消注册我的 Lambda 回调?

c# - 在 Azure 中,Google Drive Api 文件上传失败,返回 null

c# - 无法将带 [] 的索引应用于类型 'System.Dynamic.DynamicObject' 的表达式