Access C++ COM Interface from C# throws exception in GetIdsOfNames -


i have c++ com object (32 bit). com object calls c# com object , part of initialization, passes interface pointer (idispatch) c#. idea c# code can call c++ com object using interface. example: c++ calls c# com method -->

openservice(...., [..marshalas..idispacth]) 

the issue having when c# tries call interface methodnotfound exception.

internally declare interface

[comimport, guid(...), interfacetype.dual] public interface callbackinterface {     void sodata(int data) } 

i cast given idispatch pointer interface

   callbackinterface cb = (callbackinterface)inputobject;    cb.sodata(0); 

it call gives exception namenotfound in getidsofnames. interesting thing got reflector , tried debug source. exception seems coming comeventssinks.cs not connection point container or connection point. trying access interface given calling c++ object.

i gave , created simple atl com object , tried accomplish same, , works great. wanted do, comarshalinterfacethreadinstream , cogetinterfaceandrelease stream background thread , works beautifully.

but reason, c# can't call c++ original thread, let alone background thread.

i scratching head past 2 or 3 days , tried kinds of stuff beats me.

any ideas? pointers? perhaps doing silly , stupid?

idispatch designed late-binding or "dynamic" dispatch. in case, appears know shape of com interface , have interop definition (callbackinterface). so, instead of idispatch ought able use iunknown , set interfacetype interfaceisiunknown.

try that, , let know if worked.

if not, , in fact need use idispatch, make sure c++ object implements idispatch (you'll need type library , atl's idispatchimpl).

hope helps.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -