.NET新工艺沙箱不可信code [英] .net new process sandbox for untrusted code

查看:137
本文介绍了.NET新工艺沙箱不可信code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此​​,我需要在一个新的进程中运行动态编译不可信code。我发现怎么做,在一个新的AppDomain(http://msdn.microsoft.com/en-us/library/bb763046.aspx),而不是新的进程。是否有可能呢?

So I need to run dynamically compiled untrusted code in a new process. I found how to do that in a new AppDomain (http://msdn.microsoft.com/en-us/library/bb763046.aspx) but not new process. Is it possible to do?

我需要新的过程的原因是因为它是更容易捕捉标准输出,参见存储器和CPU消耗和终止它。

The reason I need new process is because it is easier to capture standard output, see memory and cpu consumption and terminate it.

最终目标是编写的在线C#编译器。

The end goal is to write online C# compiler.

推荐答案

应用程序域是一种方法来隔离.NET code系统中。进程是操作系统机制进行隔离。在某种程度上,你会放弃.NET code细微之处,并必须手动管理数据的过程之间的转移。

AppDomains are a way to isolate .NET code in a system. Processes are an operating system mechanism for isolation. To some degree you will give up the niceties of .NET code and have to manually manage the transfer of data between processes.

查看过程类。这听起来像你要么需要编译code到.exe或创建.NET的主机的.exe加载你的code。后者似乎,你可以只写主机一次,然后写入标准通信code与该主机更好。

Check out the Process class. It sounds like you either need to compile your code to a .exe, or create a host .exe in .NET that loads your code. The latter seems better as you can just write the host once and then write standard communication code with that host.

您不要在你的最终目标,提供了大量的信息,但最近的.NET版本提供各种的插件API 这可能是值得一快速浏览一下。

You don't provide a lot of information on your end goals but recent versions of .NET provide various plug-in APIs that might be worth a quick look.

这篇关于.NET新工艺沙箱不可信code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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