How to fire property changed notifications from C# to COM using IPropertyNotifySink?

青春壹個敷衍的年華 提交于 2019-12-13 04:07:36

问题


I am going crazy on this problem for the past couple of weeks. I have a C# Com object that needs to send property change notifications to a C++ Com object. An equivalent in VB would be using code that looks as follows PropertyChanged "propertyName".

In C++ the equivalent to use the CFirePropNotifyEvent class from ATL.

The C++ COM and VB COM objects do not implement a specialized events interface, so the equivalent are give above.. The C++ COM object that needs to sink the event is based around IPropertyNotifySink, afaik.

What is the equivalent in C#? i have tried:

  1. INotifyPropertyChanged from System.ComponentModel
  2. I implemented IObjectWithSite and tried to cast the site object received in setSite to IPropertyNotifySink.
    1. I cannot find an equivalent for CFirePropNotifyEvent in C++/ATL which is what the C++ code uses..

Please help..

Thanks in Advance..


回答1:


I don't think there is some automatic gateway between .NET's INotifyPropertyChanged and COM's INotifyPropertySink.

If you want a .NET object to provide COM events, you need to provide an implementation of IConnectionPointContainer in these .NET objects.

IConnectionPointContainer already exists in .NET in the System.Runtime.InteropServices.ComTypes namespace.



来源:https://stackoverflow.com/questions/4454926/how-to-fire-property-changed-notifications-from-c-sharp-to-com-using-ipropertyno

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!