cross appdomain access
Posted nanfei
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
以上是关于cross appdomain access的主要内容,如果未能解决你的问题,请参考以下文章