Groups | Blog | Home
all groups > dotnet clr > may 2007 >

dotnet clr : .NET -> COM+ ->.NET Help!


Vera
5/30/2007 1:27:00 PM
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.
Rick Strahl [MVP]
6/18/2007 6:50:00 PM
If you're running .NET on both ends of the connection you really should
screw around with COM+ if you can avoid it. Besides the configuration
nightmare there are big performance issues to deal with.

You can look into using WCF (.NET 3.0) or barring that you can look into
Remoting or possibly Enterprise Services (which uses COM+/DCOM but is more
accessible for .NET).

I don't have a clear answer for you on the COM issue - but you should be
able to release a remote reference from the client. However, there are a
lifetime issues that can get in the way. If you start up your server let it
initialize and run and you then immediately kill it with ReleaseComObject -
does that work? If so you have to look at what's possibly killing your
proxy. In your code it's possible the issue is your cast... try forcing the
type to object when you do the release.

+++ Rick ---

--

Rick Strahl
West Wind Technologies
www.west-wind.com/weblog


[quoted text, click to view]
AddThis Social Bookmark Button