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的主要内容,如果未能解决你的问题,请参考以下文章

跨 AppDomain 事件问题

laravel5.6 IlluminateDatabaseQueryException : SQLSTATE[42000]: Syntax error or access violatio(代码片

报错:PermissionError: [WinError 5] Access is denied: 'C:\Program Files\Anaconda3\Lib\site-pack(代码片

尝试在生产中部署 apex 类时出现 INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY

SecurityError: Blocked a frame with origin from access a cross-origin frame IN FIRST ACCESS

我是不是应该关注“SecurityError: Permission denied to access property on cross-origin object”日志