Managed COM server and COM client. How to subscribe to events of COM server?


hello wrote managed com server , com client in c#. when i’m trying reference com server in com client using code.

type comtype = type.gettypefromprogid("my.comserver", true); object comobj = activator.createinstance(comtype); var comserver = (comserver)comobj;

i reference new object instead of reference registered com server in rot. fix problem, use pinvoke cogetclassobject it works have problem.

private void initcomserver(object sender, routedeventargs e)         {             object comserverinstance = null;              var factory = ole32nativemethods.cogetclassobject(typeof(testcoclass).guid, registrationclasscontext.localserver, intptr.zero, typeof(iclassfactory).guid) iclassfactory;              if (factory != null)             {                 var iid = typeof(itestinterface).guid;                 factory.createinstance(null, iid, out comserverinstance);             }              this.comserver = (itestinterface)comserverinstance;         }

i don’t know how subscribe events of com server.

p.s. i attached small demo  application illustrate problem.
https://drive.google.com/file/d/0b_irffxq3qzqwejmtgjhzwhzwta/view?usp=sharing



hi compaqster,

please don't share demo on third-party website.and have no account in website. you can add demo onedrive.

here link https://onedrive.live.com/

by way, see code routedeventargs, do write code wpf application? if so, please redirect wpf  forum better support.

https://social.msdn.microsoft.com/forums/vstudio/en-us/home?forum=wpf

thanks


we trying better understand customer views on social support experience, participation in interview project appreciated if have time. helping make community forums great place.
click here participate survey.




Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'