0

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..

user543923
  • 43
  • 3

1 Answers1

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.

Simon Mourier
  • 132,049
  • 21
  • 248
  • 298
  • hmm.. good point.. i did have a (unsuccessful) go at implementing that.. is there any help available (generics impl/sample ??) – user543923 Dec 15 '10 at 23:21
  • It's hard to find. If you really want to go this route, I suggest to dive in Reflector and look around the interface, also around the AxHost class which is the CLR wrapper for AciveX objects. It's not documented but Reflector can tell a lot about it. Otherwise you can advise your own "event-like" mechanism using delegate, callbacks, etc. If it's possible in your context, it's much simpler. – Simon Mourier Dec 16 '10 at 06:37