简体   繁体   English

如何使用IPropertyNotifySink将属性更改的通知从C#触发到COM?

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

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. 我有一个C#Com对象,需要将属性更改通知发送到C ++ Com对象。 An equivalent in VB would be using code that looks as follows PropertyChanged "propertyName". VB中的等效项将使用如下代码,该代码如下PropertyChanged“ propertyName”。

In C++ the equivalent to use the CFirePropNotifyEvent class from ATL. 在C ++中,等效于使用ATL中的CFirePropNotifyEvent类。

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. C ++ COM和VB COM对象没有实现专门的事件接口,因此在上面给出了等效的接口。需要接收事件的C ++ COM对象基于IfapertyNotifySink,即afaik。

What is the equivalent in C#? C#中的等效项是什么? i have tried: 我努力了:

  1. INotifyPropertyChanged from System.ComponentModel INotifyPropertyChanged从System.ComponentModel
  2. I implemented IObjectWithSite and tried to cast the site object received in setSite to IPropertyNotifySink. 我实现了IObjectWithSite,并尝试将setSite中收到的站点对象强制转换为IPropertyNotifySink。
    1. I cannot find an equivalent for CFirePropNotifyEvent in C++/ATL which is what the C++ code uses.. 我在C ++ / ATL中找不到CFirePropNotifyEvent的等效项,这是C ++代码使用的。

Please help.. 请帮忙..

Thanks in Advance.. 提前致谢..

I don't think there is some automatic gateway between .NET's INotifyPropertyChanged and COM's INotifyPropertySink. 我认为.NET的INotifyPropertyChanged和COM的INotifyPropertySink之间没有自动网关。

If you want a .NET object to provide COM events, you need to provide an implementation of IConnectionPointContainer in these .NET objects. 如果希望.NET对象提供COM事件,则需要在这些.NET对象中提供IConnectionPointContainer的实现。

IConnectionPointContainer already exists in .NET in the System.Runtime.InteropServices.ComType s namespace. IConnectionPointContainer在.NET中已经存在于System.Runtime.InteropServices.ComType的命名空间中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM