Call a running C# application from a C++ application
-
Hi, I have a C# windows application which is already running. I have another C++ application. I want to use the C++ application to send parameters or call functions in that running C# windows application. What should I do? I am new in COM. I guess the C++ application uses something like getObject to get the running C# windows application object. Am I correct? But how can I expose the COM interface in that running C# windows application, as it is not a componenet. Thanks
-
Hi, I have a C# windows application which is already running. I have another C++ application. I want to use the C++ application to send parameters or call functions in that running C# windows application. What should I do? I am new in COM. I guess the C++ application uses something like getObject to get the running C# windows application object. Am I correct? But how can I expose the COM interface in that running C# windows application, as it is not a componenet. Thanks
Hello scchan1984, You would definitely need COM interop for a C++ COM application to connect with a C# object. The normal scenario in which this is achieved involves C# components housed in libraries. However, the catch is that your C# object is contained inside a C# application (.exe). One way you can possibly achieve interop in this case would be through .NET Remoting. To do this, you would need to make your C# class derive from MarshalByRefObject. It would also help if you could define an interface for the methods and properties that are to be exposed from your C# class to the C++ COM client. Your COM client would then need to connect with your C# class (via Remoting) by using CLR hosting. I'll see if I can come up with some example code that can achieve all this. Regards, Bio.
-
Hi, I have a C# windows application which is already running. I have another C++ application. I want to use the C++ application to send parameters or call functions in that running C# windows application. What should I do? I am new in COM. I guess the C++ application uses something like getObject to get the running C# windows application object. Am I correct? But how can I expose the COM interface in that running C# windows application, as it is not a componenet. Thanks
Hello scchan1984, I managed to develope and run a sample C++ app that creates a C# object (in a C# exe app) as a COM object. .NET Remoting can definitely do the job. However, I must indicate that the development process is quite involved. If you are interested in my sample app, pls email me : bio_lim_2004@yahoo.com Best Regards, Bio.