Mike, What I was trying to achieve in this post was to call from the second AppDomain to the first AppDomain, and get it to create the remote instances for me - to see if that would get around the remoting issue - but it seems it won't because of pathing issues - but I'm not sure if it was going to help anyway.
Dino -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Mike Woodring Sent: Saturday, 14 October 2006 03:36 To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] Get an AppDomain you didn't create > I've got a situation where my application is being loaded into 2 > AppDomains, and I would like to call into one from the other > - but I am > not creating either one, so have no AppDomain object to work with - is > there a way to get a reference to another AppDomain if you know it's > name? (...catching up...) For security reasons, there isn't a purely managed way for code running in one app domain to get a reference to another app domain w/o some cooperation (or using interop to reach outside of the CLR and have a look around). But looking at your follow up messages, there's nothing stopping you from using remoting to 'talk' across app domains. The code below[1] shows a simple app that uses one app domain to host a 'server' object, and another to take on the role of client. Just create a console project for this code and add a reference to System.Runtime.Remoting.Channels.dll in order to build & run. No config file needed. In an add-in situation like yours, you're going to want to avoid the use of config files to configure remoting, and just stick to API calls. -Mike Bear Canyon Consulting LLC http://www.bearcanyon.com http://www.pluralsight.com/mike [1] using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; class Program { static void Main() { // Create 2 app domains. One will take on the role of remoting server, // the other the role of remoting client. // AppDomain serverDomain = AppDomain.CreateDomain("Server Domain"); serverDomain.DoCallBack(InitializeServerDomain); AppDomain clientDomain = AppDomain.CreateDomain("Client Domain"); clientDomain.DoCallBack(UseClientDomain); } static void InitializeServerDomain() { Console.WriteLine("InitializeServerDomain executed in app domain '{0}'.", AppDomain.CurrentDomain.FriendlyName); // Connection string will be "tcp://host:999/widgetServer/widget". // ChannelServices.RegisterChannel(new TcpServerChannel(999), false); RemotingConfiguration.ApplicationName = "widgetServer"; RemotingConfiguration.RegisterWellKnownServiceType(typeof(Widget), "widget", WellKnownObjectMode.SingleCall); } static void UseClientDomain() { Console.WriteLine("UseClientDomain executed in app domain '{0}'.", AppDomain.CurrentDomain.FriendlyName); Widget w = (Widget)RemotingServices.Connect(typeof(Widget), "tcp://localhost:999/widgetServer/widget"); Console.WriteLine(w.GetMessage(AppDomain.CurrentDomain.FriendlyName)); } } class Widget : MarshalByRefObject { public string GetMessage(string caller) { return string.Format("Widget.GetMessage('{0}') executed in app domain '{1}'.", caller, AppDomain.CurrentDomain.FriendlyName); } } =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com