Post.Cast <> больше не работает после обновления - PullRequest
0 голосов
/ 15 апреля 2020

У меня есть следующий код (часть класса), который не менялся годами. Недавно я перешел на. net 4.7 с. net 4.5 и обновился с PostSharp 2 до Postsharp 5.0.34. Следующий код больше не выполняется и ошибки. Я уже пару дней бьюсь головой о стену, но не понимаю, почему это больше не работает? Кто-нибудь может пролить свет на это, пожалуйста?

// Фрагмент кода

[NotifyPropertyChanged]
[Serializable]
[DataContract]
public class VimConnectionInfo : ConnectionInfoBase
{
    private const int HttpsPort = 443;

    public VimConnectionInfo()
    {
        this.SetDefaultValues();

        Post.Cast<VimConnectionInfo, INotifyPropertyChanged>(this).PropertyChanged += this.HandlePropertyChanged;
    }

Из приведенного выше фрагмента ошибка возникает при выполнении строки Post.Cast. Метод HandlePropertyChanged не выполняется из-за ошибки. Сообщение об ошибке выглядит следующим образом:

Сообщение об исключении: Невозможно привести объект типа 'Advantage.Reporter.VCenter.Infrastructure.Connection.VimConnectionInfo' к типу System.ComponentModel.INotifyPropertyChanged '.

Источник: PostSharp

StackTrace: в PostSharp.Post.Cast [SourceType, TargetType] (SourceType o) в Advantage.Reporter.VCenter .Infrastructure.Connection.VimConnectionInfo..ctor () в S: \ VisualStudioProjects \ Sonar.Portable \ Advantage.Reporter.VCenter \ Infrastructure \ Connection \ VimConnectionInfo.cs: строка 33 в Advantage.Reporter.VCenter.Infrastructure.Connection.VimConne. CreateConnectionInfo () в S: \ VisualStudioProjects \ Sonar.Portable \ Advantage.Reporter.VCenter \ Infrastructure \ Connection \ VimConnectionAdapter.cs: строка 114 в Advantage.Reporter.Core.Connections.ViewModels.ConnectionCollection. <> C__DisplayClass2_. b__0 (Отправитель объекта, AddingNewEventArgs e) в S: \ VisualStudioProjects \ Sonar.Portable \ Advantage.R eporter.Core.Wpf \ Connections \ ViewModels \ ConnectionCollection.cs: строка 38 в System.ComponentModel.AddingNewEventHandler.Invoke (Отправитель объекта, AddingNewEventArgs e) в System.ComponentModel.BindingList 1.OnAddingNew(AddingNewEventArgs e) at System.ComponentModel.BindingList 1.FireAddingNew () в System.Code. BindingList 1.AddNewCore() at System.ComponentModel.BindingList 1.System.ComponentModel.IBindingList.AddNew () в Dev Express .Data.Helpers.BaseDataControllerHelper.AddNewRow () в Dev Express .Data.BaseGridControllerEx.AddNewRow ()

...