创建应用程序域并加载程序集 [英] Create application domain and load assembly

查看:25
本文介绍了创建应用程序域并加载程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个具有默认权限的应用程序域并以默认权限将程序集加载到应用程序域中并执行程序集内的方法.

I want to create an application domain with default permissions and load assembly into the application domain with default privileges and execute the methods inside the assembly.

推荐答案

您可以查看 MSDN 上的以下文章.或者,如果您想在另一个 AppDomain 中构造某个类型的实例(假设该类型具有默认构造函数):

You may take a look at the following article on MSDN. Or if you want to construct an instance of some type inside another AppDomain (assuming this type has a default constructor):

var domain = AppDomain.CreateDomain("NewAppDomain");
var path = @"C:workSomeAssembly.dll";
var t = typeof(SomeType);
var instance = (SomeType)domain.CreateInstanceFromAndUnwrap(path, t.FullName);

使用此方法返回的 instance 变量位于您新创建的应用程序域中,您已准备好操作它.

The instance variable returned with this method lives on your newly created application domain and you are ready to manipulate it.

这篇关于创建应用程序域并加载程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆