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

 

相关文章:

  • 2022-02-02
  • 2021-07-24
  • 2021-05-22
  • 2022-12-23
  • 2021-10-05
猜你喜欢
  • 2021-10-27
  • 2021-06-01
  • 2022-02-24
  • 2022-12-23
  • 2021-11-06
  • 2022-12-23
  • 2022-02-16
相关资源
相似解决方案