Hello All, My question is "How do I automate a .Net exe?"
The details are like this: Problem: I have a .exe written in .Net (C#) I want to make this similar to a COM out-of-proc server (Automation Server) so that automation clients can interact with automation objects in this .exe I found in .Net help that .Net doesn't support out-of-proc servers like COM. Irrespective of the way a .Net assembly is implemented (.DLL or .EXE) it is always treated as InProcServer in COM clients through mscoree.dll. Approach Used: In order to simulate the COM out-of-proc server I came up with the following design: Design 1: 1. Defined a set of interfaces that I expose to automation clients in a separate Interfaces DLL 2. Implemented these interfaces in the .exe as remotable types 3. Made the .exe use .Net Remoting to register these types with .Net Remoting infrastructure 4. Wrote a wrapper DLL in .Net that can talk to this .exe using .Net Remoting 5. This wrapper DLL implements the interfaces in Interfaces DLL but having just call forwarding to .exe using .Net Remoting 6. This wrapper DLL can now be used by COM clients as well as .Net clients to interact with the running .exe 7. In case the .exe is not running but clients request an automation object, the wrapper DLL starts the .exe as a separate process, waits and then forwards the request Design 2: The second design changes from first only in communication layer. Instead of using .Net remoting, Reflection is used. 1. Defined a set of interfaces that I expose to automation clients in a separate Interfaces DLL 2. Implemented these interfaces in the .exe 3. Wrote a wrapper DLL in .Net that launches this .exe using System.Reflection on a separate thread to make clients non-blocking. 4. This wrapper DLL implements the interfaces in Interfaces DLL but having just call forwarding to .exe using Reflection 5. This wrapper DLL can now be used by a COM client as well as .Net client to interact with the running .exe However, using this design, the .exe willl now run within client's process (within its domain) instead of a separate process. I would like to know if these approaches are feasible or if there exists any other simple approach that I can use. Thanks and Regards, Ramesh. =================================== This list is hosted by DevelopMentor� http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
