ImpromptuInterface
を使用して問題を解決しようとしています。 Adding Interface Implementation to ExpandoObject。'ExpandoObject'に 'PropertyChanged'の定義が含まれていません
私は基本クラスの私のインターフェイスのさまざまなプロパティにアクセスできるようになりましたが、ExpandoObjectのPropertyChangedイベントを購読できなくなりました。
トラブルシューティングの際には、問題を簡略化するために次のように説明しました。
Service.cs
using ImpromptuInterface;
public Service()
{
InitializeComponent();
dynamic expando = new ExpandoObject();
try
{
INotifyPropertyChanged obj = Impromptu.ActLike(expando);
obj.PropertyChanged += obj_PropertyChanged;
}
catch (Exception ex)
{
EventLog.WriteEntry(ex.ToString(), EventLogEntryType.Error);
}
try
{
INotifyPropertyChanged obj = Impromptu.ActLike<INotifyPropertyChanged>(expando);
obj.PropertyChanged += obj_PropertyChanged;
}
catch (Exception ex)
{
EventLog.WriteEntry(ex.ToString(), EventLogEntryType.Error);
}
}
private void obj_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
throw new NotImplementedException();
}
私は
の定義が含まれていないことを示すエラーを受け取ります'System.Dynamic.ExpandoObjectは' 'のPropertyChanged'
コンストラクタでイベントハンドラをフックアップしようとするたびに発生します。
イベントログ1
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'System.Dynamic.ExpandoObject' does not contain a definition for 'PropertyChanged'
at CallSite.Target(Closure , CallSite , Object)
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at ActLike_INotifyPropertyChanged_dc51b6c65bf147d0b5f35218102e3c11.add_PropertyChanged(PropertyChangedEventHandler value)
at Service..ctor()
イベントログ2
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'System.Dynamic.ExpandoObject' does not contain a definition for 'PropertyChanged'
at CallSite.Target(Closure , CallSite , Object)
at ActLike_INotifyPropertyChanged_dc51b6c65bf147d0b5f35218102e3c11.add_PropertyChanged(PropertyChangedEventHandler value)
at Service..ctor()
私はImpromptuInterface
この方法を使用することはできないだろうか?
私は数分間、「ImpromptuInterface」のバグのように見えました。私は[バグを報告する](https://github.com/ekonbenefits/impromptu-interface/issues) –