ImpromptuInterface
ここで抱えている問題を解決するために使用しようとしています。ExpandoObject へのインターフェイス実装の追加。
基本クラスのインターフェイスのさまざまなプロパティにアクセスできるようになりましたが、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
か?