安装DotNET 4.5时,SvcUtil/edb不会生成INotifyPropertyChange

Car*_*l R 7 .net c# wcf .net-4.0 .net-4.5

这里所有的开发计算机都安装了DotNET 4.5.最后一个安装了4.0.只有4.0的那个生成实现INotifyPropertyChange的代理类,所有其他计算机都没有.

根据MSDN/edb支持. http://msdn.microsoft.com/en-us/library/aa347733(v=vs.110).aspx

我们使用的开关是:/ o/ct/r/edb/n/noconfig/tcv

这是从4.0计算机生成的:

public partial class OrganizationEdition : MyCompany.MyProject.Client.Win.ServiceProxy.UpdateableEntity, System.ComponentModel.INotifyPropertyChanged
{

    private string CommentField;

    private System.DateTime ValidFromField;

    private System.Nullable<System.DateTime> ValidToField;

    [System.Runtime.Serialization.DataMemberAttribute()]
    public string Comment
    {
        get
        {
            return this.CommentField;
        }
        set
        {
            if ((object.Equals(this.CommentField, value) != true))
            {
                this.CommentField = value;
                this.RaisePropertyChanged("Comment");
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

这是来自4.5计算机(使用Windows SDK 7.0A):

public partial class OrganizationEdition : MyCompany.MyProject.Client.Win.ServiceProxy.UpdateableEntity
{

    private string CommentField;

    private System.DateTime ValidFromField;

    private System.Nullable<System.DateTime> ValidToField;

    [System.Runtime.Serialization.DataMemberAttribute()]
    public string Comment
    {
        get
        {
            return this.CommentField;
        }
        set
        {
            this.CommentField = value;
        }
    }
Run Code Online (Sandbox Code Playgroud)

Rys*_*gan 2

我无法告诉你为什么它不起作用。

不过我可以给你一个技巧来解决这个问题。您可以使用.tt文件(T4 模板)来恢复编译时解决方案中存在的特定类的属性设置器中丢失的通知。

Pluralsight 上提供了如何实现此类功能的示例,MSDN 上提供了有关 T4 模板语法的更多信息。