|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to get the Appdomain Object from AppDomain IDI have a AppDomain ID, how do I get the instance of the AppDomain
Object? Please advice. Thanks in advance. John John wrote:
> I have a AppDomain ID, how do I get the instance of the AppDomain There might be a simpler way, but it looks to me like the only way to> Object? 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+group%3Amicrosoft.public.dotnet.*&rnum=5#9df14bf0af393c28> 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. Thx, but the EnumDomains only enumates the AppDomain in the current
process, how about the AppDomain in other processes? Jon Shemitz wrote: Show quote > 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+group%3Amicrosoft.public.dotnet.*&rnum=5#9df14bf0af393c28> > > 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. I doubt that this is exposed in a readily available way.
What is it that you are trying to do? -- Show quote- Nicholas Paldino [.NET/C# MVP] - mvp@spam.guard.caspershouse.com "John" <john***@yahoo.com> wrote in message news:1158092028.572376.62600@d34g2000cwd.googlegroups.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+group%3Amicrosoft.public.dotnet.*&rnum=5#9df14bf0af393c28> >> >> 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. > 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: Show quote > 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] > - mvp@spam.guard.caspershouse.com > > "John" <john***@yahoo.com> wrote in message > news:1158092028.572376.62600@d34g2000cwd.googlegroups.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+group%3Amicrosoft.public.dotnet.*&rnum=5#9df14bf0af393c28> > >> > >> 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. > > "John" <john***@yahoo.com> wrote in message You cannot directly use objects in another application, you need a proxy. news:1158160939.979310.289370@e63g2000cwd.googlegroups.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. The COM Running Object Table creates a proxy when you lookup an object. Show quote > 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] >> - mvp@spam.guard.caspershouse.com >> >> "John" <john***@yahoo.com> wrote in message >> news:1158092028.572376.62600@d34g2000cwd.googlegroups.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+group%3Amicrosoft.public.dotnet.*&rnum=5#9df14bf0af393c28> >> >> >> >> 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. >> > > I believe if you are calling the object from another appdomain, the
proxy is automatically created for you. Ben Voigt wrote: Show quote > "John" <john***@yahoo.com> wrote in message > news:1158160939.979310.289370@e63g2000cwd.googlegroups.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] > >> - mvp@spam.guard.caspershouse.com > >> > >> "John" <john***@yahoo.com> wrote in message > >> news:1158092028.572376.62600@d34g2000cwd.googlegroups.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+group%3Amicrosoft.public.dotnet.*&rnum=5#9df14bf0af393c28> > >> >> > >> >> 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. > >> > > > John wrote:
> Basically, I want to use it as COM Global Interface Table, one app It doesn't sound simpler! Remoting is very easy to use at a Hello> 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. 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.
Show quote
"Jon Shemitz" <j**@midnightbeach.com> wrote in message If you don't want to use Remoting, then try Web Services (WSDL) for which news:45083F14.ADB1582D@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. ..NET also has good support. Show quote > > 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. 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: Show quote > 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. 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: Show quote > 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. "John" <john***@yahoo.com> wrote in message You can't use this ITF pointer in another domain, you need a remoting proxy. news:1158160939.979310.289370@e63g2000cwd.googlegroups.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. 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. 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\testAppDomainCsharp\plugin\bin\Debug\plugin.dll", "plugin.test"); Ginterface.ITest ttx=( Ginterface.ITest )app.GetData("Name"); string x2 = ttx.GetName(); } Willy Denoyette [MVP] wrote: Show quote > "John" <john***@yahoo.com> wrote in message > news:1158160939.979310.289370@e63g2000cwd.googlegroups.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. |
|||||||||||||||||||||||