什么是 .NET 应用程序域? [英] What is a .NET application domain?

查看:26
本文介绍了什么是 .NET 应用程序域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

特别是,在两个不同的应用程序域中运行代码的含义是什么?

In particular, what are the implications of running code in two different application domains?

数据通常如何跨应用程序域边界传递?它与跨进程边界传递数据相同吗?我很想了解更多关于这种抽象及其用途的信息.

How is data normally passed across the application domain boundary? Is it the same as passing data across the process boundary? I'm curious to know more about this abstraction and what it is useful for.

我不知道对 AppDomain 类的现有覆盖不了解应用程序域

推荐答案

An AppDomain 基本上提供了一个隔离区域,在该区域中代码在进程内部运行.

An AppDomain basically provides an isolated region in which code runs inside of a process.

一种简单的方式来思考它几乎就像一个位于主进程中的轻量级进程.每个 AppDomain 完全隔离地存在于一个进程中,这使您可以安全地运行代码(如果需要,可以在不拆除整个进程的情况下卸载它),具有单独的安全性等.

An easy way to think of it is almost like a lighter-weight process sitting inside of your main process. Each AppDomain exists within a process in complete isolation, which allows you to run code safely (it can be unloaded without tearing down the whole process if needed), with separate security, etc.

至于您的具体情况 - 如果您在一个进程内的 2 个不同 AppDomain 中运行代码,则代码将单独运行.AppDomains 之间的任何通信都将通过 MarshallByRefObject 进行序列化或处理.在这方面,它的行为非常类似于使用远程处理.这提供了极大的安全性 - 您可以运行您不信任的代码,如果它出现错误,也不会影响您.

As to your specifics - if you run code in 2 different AppDomains within a process, the code will run in isolation. Any communication between the AppDomains will get either serialized or handled via MarshallByRefObject. It behaves very much like using remoting in this regard. This provides a huge amount of security - you can run code that you don't trust, and if it does something wrong, it will not affect you.

MSDN 对应用程序域的描述中有更多详细信息.

There are many more details in MSDN's description of Application Domains.

这篇关于什么是 .NET 应用程序域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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