We have a remote server application called from a client application.
The server application is a .NET application but built with COM supportability and included as a COM+ service on one system. The client application, which is also written in .NET calls the COM+ application remotely(from one or more different machines) The invocation of the remote object is done by the call below
Type oType = Type.GetTypeFromProgID("<Program ID>", "<Server Name>")
Activator.CreateInstance(oType ) as ...
After I get the functionality from the remote application, I try to close this instance thus created by
Marshal.ReleaseComObject (oSrvProxy)
Now I get the exception "MSCORLIB specified cast is not valid." I think the problem is because our server object is not a __ComObject or derived from a __ComObject. It is a CLR object. However, for the .NET 1.1 framework, we have observed that when the client application is killed, the server application memory is released too. In .NET framework 2.0, we noticed that it gives an exception when the client application is closed.
Now coming to our problem
1. As the objects are in memory and will be removed only when the application closes and if the connection is terminated, then the object stays in the server memory till the server application is restarted. We need to explicitly release this server object so that the server object is cleared from the server memory after the time that is set for the object to be alive (time for idle shutdown), explicitly, rather than at the client application closure
2. The change in behavior of .NET framwork 2.0 raises exception at the closure of the client application.
Now coming to my questions
1. Instead of building the .NET server application as a COM+ application and using it as a COM+ server application for .NET clients, isn't there a better way to design to use the functionalities of the remote server application? What do you suggest?
2. Is there any means by which I can programmatically release the server object from the client other than at the application closure? As I mentioned before, Marshal.ReleaseComObject() is of no use.
Thanks a lot for your valuable time. If you need me to post this in thescripts, i can also do that.
Thanks and warm regards,
- Midhun George.