c# use an object instance across appdomains

H

hufman

Hi.

I need to use an object instance in 2 differnet AppDomains, meaning
changing his fields and such...
I tried to do it with Remoting but i couldn't find a way to refernce a
specific instance in the remoted appdomain where the object was
created.

what can i do?
 
H

hufman

Does the remote object derive from MarshalByRefObj? Can you post a
short-but-complete code sample that illustrates the issue? A description of
the problem is insufficient here because nobody knows what your code is doing.
-- Peter
Site:http://www.eggheadcafe.com
UnBlog:http://petesbloggerama.blogspot.com
Short Urls & more:http://ittyurl.net







-הר××” טקסט מצוטט-

i want to do something like this:

public class MyPoint
{
Point p = new Point();

public void func1() {
for (int i = 0; i < 10; i++)
{
p.x++;
}
}
public void func2()
{
for (int i = 0; i < 10; i++)
{
p.y++;
}
}
}

public class MyClass
{
public static void Main()
{
AppDomain newDomain1 = AppDomain.CreateDomain("Domain:
1" );
AppDomain newDomain2 = AppDomain.CreateDomain("Domain:
2" );

MyPoint mypoint = new MyPoint();
newDomain1.DoCallBack(mypoint.func1);
newDomain2.DoCallBack(mypoint.func2);
}
}
}

i want this code to work and p would result in (10,10). of course this
would not work as it is and i need to insert some code that will
transfer p through some sort of TCP connection between the 2
appdomains each time that p is being reference in the domains.
this is the only solution that i found.
is there an easier way to share p between the 2 appdomains?
 

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