Do I need to "release" a reference to an object living in a different app-domain.

P

Peter Strøiman

Hi.

I have a component that needs to run in its own execution environment and
with its own configuration file.

Therefore I create a new AppDomain at runtime. Let's say that my component
exists in "a.dll"

there I have

public class MyClass : MarshalByRefObject
{
public void test();
}

When I create my component, I write

AppDomain newDomain = AppDomain.Create( ... );
MyClass newObject = (MyClass)newDomain.CreateInstanceFromAndUnwrap( "a.dll",
"MyClass" )
newObject.test();

This all works perfectly fine.

My question is - now that I create an object that is a proxy for an object
in a different AppDomain, do I need to do anything special to clean up after
using the object.

Thanks in advance,
Pete
 
D

David Browne

Peter Strøiman said:
Hi.

I have a component that needs to run in its own execution environment and
with its own configuration file.

Therefore I create a new AppDomain at runtime. Let's say that my component
exists in "a.dll"

there I have

public class MyClass : MarshalByRefObject
{
public void test();
}

When I create my component, I write

AppDomain newDomain = AppDomain.Create( ... );
MyClass newObject = (MyClass)newDomain.CreateInstanceFromAndUnwrap( "a.dll",
"MyClass" )
newObject.test();

This all works perfectly fine.

My question is - now that I create an object that is a proxy for an object
in a different AppDomain, do I need to do anything special to clean up after
using the object.

No. Remember there is only one managed heap per process. When your proxy
becomes unreachable, the remote object will be unreachable and will be
collected. But the other AppDomain will not shut itself down.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top