WCF公共属性 - 未获取序列化 - 对象引用未设置为对象错误的引用

时间:2013-07-17 10:42:43

标签: wcf

我有一个问题,我有私人领域和公共财产。这是我装饰我的类和属性的方式。

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.Serialization;
using System.Xml.Serialization;

    [DataContract]
    [KnownType(typeof(XDocument))]
    public abstract class DocumentBase
    {
        #region Public Contructors

        /// <summary>
        /// Initialises a new instance of the DocumentBase class
        /// </summary>
        protected DocumentBase()
        {
            Id = Guid.NewGuid();
            Roles = new List<string>();
        }

        #endregion

        #region Private Fields

        /// <summary>
        /// Holds the filename of the document
        /// </summary>
        [DataMember]
        private string fileName;

        private IFileNameCleaner fileNameCleaner;

        #endregion

        #region Protected Properties

        protected IFileNameCleaner FileNameCleaner
        {
            get
            {
                return fileNameCleaner;
            }

            set
            {
                fileNameCleaner = value;
            }
        }

        #endregion

        #region Public Properties

        [DataMember]
        public string FileName
        {
            get
            {
                string newFileName = this.fileName;
                if (FileNamePrefix > 0)
                {
                    newFileName = FileNamePrefix + "_" + fileName;
                }

                return fileNameCleaner.FileName(newFileName);
            }
          private  set
            {
                fileName = value;
            }
        }

错误:

FileName没有获得序列化,任何人都可以告诉我错过了什么?

1 个答案:

答案 0 :(得分:0)

从filename属性中,返回FileNameCleaner的FileName属性。这个返回的filenamecleaner.FileName属性是否可序列化?