Type.GetProperties()在调试和发布模式下的工作方式不同

时间:2014-02-20 16:55:51

标签: c# .net reflection

我有一个调用t.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)的代码,其中t是类CTopic的类型。该类包含属性Key,其方式如下所示:

    public interface IKey
    {
        object Key { get; set; }
    }

    public interface IKey<T> : IKey
    {
        T Key { get; set; }
    }

    public abstract class CBean<T> : IKey<T>
    {
        public abstract T Key { get; set; }
        object IKey.Key { get; set;}
    }

    public class CTopic : CBean<string>
    {
        public override string Key
        {
            get { return string.Empty; }
            set { string s = value; }
        }
    }

GetProperties方法正在为&#34; Key&#34;返回PropertyInfo(等等) debug mode中的财产。但是同样的代码为&#34; Key&#34;返回两个PropertyInfo [s]。 release mode中的财产。

enter image description here

我尝试通过创建一个单独的项目来复制它,并且引用包含CTopic类的程序集并且类似地调用GetProperties但不能在调试和释放模式中复制奇怪的情况。

是否存在任何项目级别设置或其他设置?

0 个答案:

没有答案