473,228 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,228 software developers and data experts.

How to get the Appdomain Object from AppDomain ID

I have a AppDomain ID, how do I get the instance of the AppDomain
Object?
Please advice.
Thanks in advance.
John

Sep 12 '06 #1
12 8182
John wrote:
I have a AppDomain ID, how do I get the instance of the AppDomain
Object?
There might be a simpler way, but it looks to me like the only way to
do this is to enumerate the app domains in the process, checking their
id. There doesn't seem to be an unmanaged way to enumerate app domains
- see

<http://groups.google.com/group/microsoft.public.dotnet.framework.clr/browse_frm/thread/dba9c445ad8d5c3/9df14bf0af393c28?lnk=st&q=enumerate+appdomain+grou p%3Amicrosoft.public.dotnet.*&rnum=5#9df14bf0af393 c28>

for some code that uses the unmanaged, debug interface.

--

..NET 2.0 for Delphi Programmers www.midnightbeach.com/.net
Delphi skills make .NET easy to learn Great reviews & good sales.
Sep 12 '06 #2
Thx, but the EnumDomains only enumates the AppDomain in the current
process, how about the AppDomain in other processes?
Jon Shemitz wrote:
John wrote:
I have a AppDomain ID, how do I get the instance of the AppDomain
Object?

There might be a simpler way, but it looks to me like the only way to
do this is to enumerate the app domains in the process, checking their
id. There doesn't seem to be an unmanaged way to enumerate app domains
- see

<http://groups.google.com/group/microsoft.public.dotnet.framework.clr/browse_frm/thread/dba9c445ad8d5c3/9df14bf0af393c28?lnk=st&q=enumerate+appdomain+grou p%3Amicrosoft.public.dotnet.*&rnum=5#9df14bf0af393 c28>

for some code that uses the unmanaged, debug interface.

--

.NET 2.0 for Delphi Programmers www.midnightbeach.com/.net
Delphi skills make .NET easy to learn Great reviews & good sales.
Sep 12 '06 #3
I doubt that this is exposed in a readily available way.

What is it that you are trying to do?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John" <jo*****@yahoo.comwrote in message
news:11*********************@d34g2000cwd.googlegro ups.com...
Thx, but the EnumDomains only enumates the AppDomain in the current
process, how about the AppDomain in other processes?
Jon Shemitz wrote:
>John wrote:
I have a AppDomain ID, how do I get the instance of the AppDomain
Object?

There might be a simpler way, but it looks to me like the only way to
do this is to enumerate the app domains in the process, checking their
id. There doesn't seem to be an unmanaged way to enumerate app domains
- see

<http://groups.google.com/group/microsoft.public.dotnet.framework.clr/browse_frm/thread/dba9c445ad8d5c3/9df14bf0af393c28?lnk=st&q=enumerate+appdomain+grou p%3Amicrosoft.public.dotnet.*&rnum=5#9df14bf0af393 c28>

for some code that uses the unmanaged, debug interface.

--

.NET 2.0 for Delphi Programmers www.midnightbeach.com/.net
Delphi skills make .NET easy to learn Great reviews & good sales.

Sep 13 '06 #4
Basically, I want to use it as COM Global Interface Table, one app
Appdomain running in one process, setup some object it wants to expose
using Appdomain.SetData, another app in another process can use
IcorPublish to enumerate all the appDomain in the system and find out
the particular domain it is interesting. Get the AppDomainID, from the
AppDomainID, get the AppDomain Object, using AppDomain.GetData get the
Object, casting the Object to an interface pointer and use it.
Of course I know that I could achieve the same thing with .NET
Remoting, but it seem to me that if I could somehow get the AppDomain
Object from the AppDomainID, it will be much simpler than using
Remoting.
John
Nicholas Paldino [.NET/C# MVP] wrote:
I doubt that this is exposed in a readily available way.

What is it that you are trying to do?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John" <jo*****@yahoo.comwrote in message
news:11*********************@d34g2000cwd.googlegro ups.com...
Thx, but the EnumDomains only enumates the AppDomain in the current
process, how about the AppDomain in other processes?
Jon Shemitz wrote:
John wrote:

I have a AppDomain ID, how do I get the instance of the AppDomain
Object?

There might be a simpler way, but it looks to me like the only way to
do this is to enumerate the app domains in the process, checking their
id. There doesn't seem to be an unmanaged way to enumerate app domains
- see

<http://groups.google.com/group/microsoft.public.dotnet.framework.clr/browse_frm/thread/dba9c445ad8d5c3/9df14bf0af393c28?lnk=st&q=enumerate+appdomain+grou p%3Amicrosoft.public.dotnet.*&rnum=5#9df14bf0af393 c28>

for some code that uses the unmanaged, debug interface.

--

.NET 2.0 for Delphi Programmers www.midnightbeach.com/.net
Delphi skills make .NET easy to learn Great reviews & good sales.
Sep 13 '06 #5

"John" <jo*****@yahoo.comwrote in message
news:11**********************@e63g2000cwd.googlegr oups.com...
Basically, I want to use it as COM Global Interface Table, one app
Appdomain running in one process, setup some object it wants to expose
using Appdomain.SetData, another app in another process can use
IcorPublish to enumerate all the appDomain in the system and find out
the particular domain it is interesting. Get the AppDomainID, from the
AppDomainID, get the AppDomain Object, using AppDomain.GetData get the
Object, casting the Object to an interface pointer and use it.
Of course I know that I could achieve the same thing with .NET
Remoting, but it seem to me that if I could somehow get the AppDomain
Object from the AppDomainID, it will be much simpler than using
Remoting.
You cannot directly use objects in another application, you need a proxy.
The COM Running Object Table creates a proxy when you lookup an object.
John
Nicholas Paldino [.NET/C# MVP] wrote:
>I doubt that this is exposed in a readily available way.

What is it that you are trying to do?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John" <jo*****@yahoo.comwrote in message
news:11*********************@d34g2000cwd.googlegr oups.com...
Thx, but the EnumDomains only enumates the AppDomain in the current
process, how about the AppDomain in other processes?
Jon Shemitz wrote:
John wrote:

I have a AppDomain ID, how do I get the instance of the AppDomain
Object?

There might be a simpler way, but it looks to me like the only way to
do this is to enumerate the app domains in the process, checking their
id. There doesn't seem to be an unmanaged way to enumerate app domains
- see

<http://groups.google.com/group/microsoft.public.dotnet.framework.clr/browse_frm/thread/dba9c445ad8d5c3/9df14bf0af393c28?lnk=st&q=enumerate+appdomain+grou p%3Amicrosoft.public.dotnet.*&rnum=5#9df14bf0af393 c28>

for some code that uses the unmanaged, debug interface.

--

.NET 2.0 for Delphi Programmers www.midnightbeach.com/.net
Delphi skills make .NET easy to learn Great reviews & good sales.

Sep 13 '06 #6
John wrote:
Basically, I want to use it as COM Global Interface Table, one app
Appdomain running in one process, setup some object it wants to expose
using Appdomain.SetData, another app in another process can use
IcorPublish to enumerate all the appDomain in the system and find out
the particular domain it is interesting. Get the AppDomainID, from the
AppDomainID, get the AppDomain Object, using AppDomain.GetData get the
Object, casting the Object to an interface pointer and use it.
Of course I know that I could achieve the same thing with .NET
Remoting, but it seem to me that if I could somehow get the AppDomain
Object from the AppDomainID, it will be much simpler than using
Remoting.
It doesn't sound simpler! Remoting is very easy to use at a Hello
World level, and that is perfectly adequate for many applications. It
also supports additional complexity (lease management, channel sinks,
&c) for the apps that need it. It's documented and supported; there
are users out there who've probably solved any problem you'll run
into.

Seems a lot simpler than building your own infrastructure and
increasing your reliance on (ugh!) COM.

--

..NET 2.0 for Delphi Programmers www.midnightbeach.com/.net
Delphi skills make .NET easy to learn Great reviews & good sales.
Sep 13 '06 #7

"Jon Shemitz" <jo*@midnightbeach.comwrote in message
news:45***************@midnightbeach.com...
John wrote:
>Basically, I want to use it as COM Global Interface Table, one app
Appdomain running in one process, setup some object it wants to expose
using Appdomain.SetData, another app in another process can use
IcorPublish to enumerate all the appDomain in the system and find out
the particular domain it is interesting. Get the AppDomainID, from the
AppDomainID, get the AppDomain Object, using AppDomain.GetData get the
Object, casting the Object to an interface pointer and use it.
Of course I know that I could achieve the same thing with .NET
Remoting, but it seem to me that if I could somehow get the AppDomain
Object from the AppDomainID, it will be much simpler than using
Remoting.

It doesn't sound simpler! Remoting is very easy to use at a Hello
World level, and that is perfectly adequate for many applications. It
also supports additional complexity (lease management, channel sinks,
&c) for the apps that need it. It's documented and supported; there
are users out there who've probably solved any problem you'll run
into.
If you don't want to use Remoting, then try Web Services (WSDL) for which
..NET also has good support.
>
Seems a lot simpler than building your own infrastructure and
increasing your reliance on (ugh!) COM.

--

.NET 2.0 for Delphi Programmers www.midnightbeach.com/.net
Delphi skills make .NET easy to learn Great reviews & good sales.

Sep 13 '06 #8
no, not , I am not using COM, when I talk about COM GIT, I am talking
about I want to using the feature similiar to COM GIT, what I want to
do has nothing to do with COM.
I still beleive that if somehow I could get the AppDomain Object from
an AppDomain ID, it will be much easier than the remoting, because all
I need to do is the following

1) AppDomain app=GetAppDomainFromAppDomainID();
2) IMyInterface imf =(IMyInterface )app.GetData();
3) imf.method1();

Jon Shemitz wrote:
John wrote:
Basically, I want to use it as COM Global Interface Table, one app
Appdomain running in one process, setup some object it wants to expose
using Appdomain.SetData, another app in another process can use
IcorPublish to enumerate all the appDomain in the system and find out
the particular domain it is interesting. Get the AppDomainID, from the
AppDomainID, get the AppDomain Object, using AppDomain.GetData get the
Object, casting the Object to an interface pointer and use it.
Of course I know that I could achieve the same thing with .NET
Remoting, but it seem to me that if I could somehow get the AppDomain
Object from the AppDomainID, it will be much simpler than using
Remoting.

It doesn't sound simpler! Remoting is very easy to use at a Hello
World level, and that is perfectly adequate for many applications. It
also supports additional complexity (lease management, channel sinks,
&c) for the apps that need it. It's documented and supported; there
are users out there who've probably solved any problem you'll run
into.

Seems a lot simpler than building your own infrastructure and
increasing your reliance on (ugh!) COM.

--

.NET 2.0 for Delphi Programmers www.midnightbeach.com/.net
Delphi skills make .NET easy to learn Great reviews & good sales.
Sep 13 '06 #9
I believe if you are calling the object from another appdomain, the
proxy is automatically created for you.
Ben Voigt wrote:
"John" <jo*****@yahoo.comwrote in message
news:11**********************@e63g2000cwd.googlegr oups.com...
Basically, I want to use it as COM Global Interface Table, one app
Appdomain running in one process, setup some object it wants to expose
using Appdomain.SetData, another app in another process can use
IcorPublish to enumerate all the appDomain in the system and find out
the particular domain it is interesting. Get the AppDomainID, from the
AppDomainID, get the AppDomain Object, using AppDomain.GetData get the
Object, casting the Object to an interface pointer and use it.
Of course I know that I could achieve the same thing with .NET
Remoting, but it seem to me that if I could somehow get the AppDomain
Object from the AppDomainID, it will be much simpler than using
Remoting.

You cannot directly use objects in another application, you need a proxy.
The COM Running Object Table creates a proxy when you lookup an object.
John
Nicholas Paldino [.NET/C# MVP] wrote:
I doubt that this is exposed in a readily available way.

What is it that you are trying to do?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John" <jo*****@yahoo.comwrote in message
news:11*********************@d34g2000cwd.googlegro ups.com...
Thx, but the EnumDomains only enumates the AppDomain in the current
process, how about the AppDomain in other processes?
Jon Shemitz wrote:
John wrote:

I have a AppDomain ID, how do I get the instance of the AppDomain
Object?

There might be a simpler way, but it looks to me like the only way to
do this is to enumerate the app domains in the process, checking their
id. There doesn't seem to be an unmanaged way to enumerate app domains
- see

<http://groups.google.com/group/microsoft.public.dotnet.framework.clr/browse_frm/thread/dba9c445ad8d5c3/9df14bf0af393c28?lnk=st&q=enumerate+appdomain+grou p%3Amicrosoft.public.dotnet.*&rnum=5#9df14bf0af393 c28>

for some code that uses the unmanaged, debug interface.

--

.NET 2.0 for Delphi Programmers www.midnightbeach.com/.net
Delphi skills make .NET easy to learn Great reviews & good sales.
Sep 13 '06 #10
no, not , I am not using COM, when I talk about COM GIT, I am talking
about I want to using the feature similiar to COM GIT, what I want to
do has nothing to do with COM.
I still beleive that if somehow I could get the AppDomain Object from
an AppDomain ID, it will be much easier than the remoting, because all
I need to do is the following

1) AppDomain app=GetAppDomainFromAppDomainID();
2) IMyInterface imf =(IMyInterface )app.GetData();
3) imf.method1();

Jon Shemitz wrote:
John wrote:
Basically, I want to use it as COM Global Interface Table, one app
Appdomain running in one process, setup some object it wants to expose
using Appdomain.SetData, another app in another process can use
IcorPublish to enumerate all the appDomain in the system and find out
the particular domain it is interesting. Get the AppDomainID, from the
AppDomainID, get the AppDomain Object, using AppDomain.GetData get the
Object, casting the Object to an interface pointer and use it.
Of course I know that I could achieve the same thing with .NET
Remoting, but it seem to me that if I could somehow get the AppDomain
Object from the AppDomainID, it will be much simpler than using
Remoting.

It doesn't sound simpler! Remoting is very easy to use at a Hello
World level, and that is perfectly adequate for many applications. It
also supports additional complexity (lease management, channel sinks,
&c) for the apps that need it. It's documented and supported; there
are users out there who've probably solved any problem you'll run
into.

Seems a lot simpler than building your own infrastructure and
increasing your reliance on (ugh!) COM.

--

.NET 2.0 for Delphi Programmers www.midnightbeach.com/.net
Delphi skills make .NET easy to learn Great reviews & good sales.
Sep 13 '06 #11

"John" <jo*****@yahoo.comwrote in message
news:11**********************@e63g2000cwd.googlegr oups.com...
| Basically, I want to use it as COM Global Interface Table, one app
| Appdomain running in one process, setup some object it wants to expose
| using Appdomain.SetData, another app in another process can use
| IcorPublish to enumerate all the appDomain in the system and find out
| the particular domain it is interesting. Get the AppDomainID, from the
| AppDomainID, get the AppDomain Object, using AppDomain.GetData get the
| Object, casting the Object to an interface pointer and use it.

You can't use this ITF pointer in another domain, you need a remoting proxy.
The pointer is only relevant for the Apllication Domain it's born in (even
if in the same process). You need to use remoting, or create your own proxy,
but what makes you thing it will be simpler than using Remoting.
Willy.
Sep 14 '06 #12
The remoting proxy is automatically created for you when you get the
object reference from another domain.

(I just need to get the AppDomainObject from AppDomainID from another
process.)

I already got it work if the AppDomain is is in the same process , the
following code is working:

Interface Project

using System;
using System.Collections.Generic;
using System.Text;

namespace Ginterface
{
public interface ITest
{
string GetName();

}
}

Object Project
using System;
using System.Runtime.Remoting;
using System.Collections.Generic;
using System.Text;

namespace plugin
{
public class test : System.MarshalByRefObject ,Ginterface.ITest
{
public string GetName()
{

return "John";
}
public test()
{
AppDomain.CurrentDomain.SetData("Name", this);
}

}
}
Client Project

static void Main(string[] args)
{

AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationName = "TestApp";
setup.ApplicationBase =
setup.PrivateBinPath =
AppDomain.CurrentDomain.BaseDirectory;//@"C:\Project\testAppDomainCsharp\plugin\bin\Debug" ;
AppDomain app=AppDomain.CreateDomain("Test",null,setup);

ObjectHandle
oh=app.CreateInstanceFrom(@"C:\Project\testAppDoma inCsharp\plugin\bin\Debug\plugin.dll",
"plugin.test");
Ginterface.ITest ttx=( Ginterface.ITest )app.GetData("Name");
string x2 = ttx.GetName();

}
Willy Denoyette [MVP] wrote:
"John" <jo*****@yahoo.comwrote in message
news:11**********************@e63g2000cwd.googlegr oups.com...
| Basically, I want to use it as COM Global Interface Table, one app
| Appdomain running in one process, setup some object it wants to expose
| using Appdomain.SetData, another app in another process can use
| IcorPublish to enumerate all the appDomain in the system and find out
| the particular domain it is interesting. Get the AppDomainID, from the
| AppDomainID, get the AppDomain Object, using AppDomain.GetData get the
| Object, casting the Object to an interface pointer and use it.

You can't use this ITF pointer in another domain, you need a remoting proxy.
The pointer is only relevant for the Apllication Domain it's born in (even
if in the same process). You need to use remoting, or create your own proxy,
but what makes you thing it will be simpler than using Remoting.
Willy.
Sep 14 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Daylor | last post by:
first of all , PLEASE,say somthing..about my post. any reply will be nice to read. i have vb.app , with 2 appdomains. (now, in the next section , ill write "appdomain create" ,means a code in...
5
by: Chris | last post by:
Hi I have a scenario where I've created another AppDomain to dynamically load a DLL(s) into. In this newly loaded DLL I want to call a static method on a class. The problem arise is that I have...
1
by: MatthewRoberts | last post by:
Howdy All, I am having difficulty with two-way communication across AppDomains in an attempt to dynamically script applications. Everything works as expected, except when using ByRef parameters....
8
by: A. Elamiri | last post by:
Hello, I created a small app which acts as a services manager. I basically drop a DLL in a Services folder and set the frequency through the application for how often do I want the code in the...
6
by: Wal Turner | last post by:
Hi there. There are various snippets on forums regarding issues with AppDomain.Unload and how it just doesnt work. Fortunately, I got it working with the base case, after much fiddling. Consider...
1
by: Raveendra M | last post by:
Hi! I am working with ASP.NET application. In my page I am creating one Application Domain and in that domain I am calling my DLL. Using the methods of the dll. And unloading the Application...
3
by: hB | last post by:
Hi. Error = "The configuration system can only be set once. Configuration system is already set" Exception Details: System.InvalidOperationExcepti­on: The configuration system can only...
0
by: Zeya | last post by:
Situation: Using C#, ASP.Net Requirement: 1. ASP.net application with virtual hosting service. 2. Requires a service that will run every predefined frequency in minutes (2, 30, 100, 10000)...
4
by: illegal.prime | last post by:
Hi all, I'm getting unexpected results when trying to preload assemblies into an AppDomain I'm creating. Upon creation of the AppDomain - I attach an AssemblyResolve to both my current AppDomain...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.