cross appdomain access
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp6 { class Program { static string greetings = "PONG!"; static void Main(string[] args) { AppDomain otherDomain = AppDomain.CreateDomain("otherDomain"); greetings = "PING!"; MyCallBack(); otherDomain.DoCallBack(new CrossAppDomainDelegate(MyCallBack)); // Output: // PING! from defaultDomain // PONG! from otherDomain Console.In.ReadLine(); } public static void MyCallBack() { string name = AppDomain.CurrentDomain.FriendlyName; if (name == AppDomain.CurrentDomain.SetupInformation.ApplicationName) { name = "defaultDomain"; } Console.WriteLine(greetings + " from " + name); var list = AppDomain.CurrentDomain.GetAssemblies().ToList(); } } }
result:
PING! from defaultDomain PONG! from otherDomain
桂棹兮兰桨,击空明兮溯流光。