visual-studio Visual Studio 托管进程的目的是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2069940/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the purpose of the Visual Studio Hosting Process?
提问by Frederick The Fool
When debugging a program using Visual Studio you are given the option to Enable the Visual Studio hosting process. What is this purpose of this option and what effect does it have?
使用 Visual Studio 调试程序时,您可以选择Enable the Visual Studio hosting process. 这个选项的目的是什么,它有什么效果?
采纳答案by Hans Passant
The MSDN library doesn't give very good info on the "hosting process". The last two features listed in Eric's link are actually problems induced by the feature. There's another one that you're bound to run into sooner or later: it uses a different app.config file. The active one is named yourapp.vshost.exe.config. Watch out for this when you make manual changes to the file.
MSDN 库没有提供关于“托管过程”的很好的信息。Eric 链接中列出的最后两个功能实际上是由该功能引起的问题。还有一个你迟早会遇到的:它使用不同的 app.config 文件。活动的名为 yourapp.vshost.exe.config。当您对文件进行手动更改时,请注意这一点。
Another feature it supports that's very visible when you debug your app but isn't mentioned anywhere is what happens to the output produced by Console.Write(). In a non-console mode app, it gets redirected to the IDE's Output window. Very useful.
它支持的另一个功能在您调试应用程序时非常明显,但在任何地方都没有提及,即 Console.Write() 生成的输出会发生什么。在非控制台模式应用程序中,它被重定向到 IDE 的输出窗口。很有用。
The term "hosting" refers to a feature of the CLR, it can be "hosted". Examples of custom CLR hosts are SQL Server and ASP.NET. Hosting allows one to configure the CLR before it gets started. One primary use of this is configuring the primary AppDomain and setting up custom security policies. Which is exactly what the hosting process is doing.
术语“托管”是指 CLR 的一项功能,它可以是“托管”的。自定义 CLR 主机的示例是 SQL Server 和 ASP.NET。托管允许在 CLR 启动之前对其进行配置。它的一个主要用途是配置主 AppDomain 并设置自定义安全策略。这正是托管进程正在做的事情。
A good example of a custom CLR host is available in this question.
这个问题中提供了一个很好的自定义 CLR 主机示例。
Long story short: in debug mode you are running with a customized version of the CLR, one that improves the debugging experience.
长话短说:在调试模式下,您运行的是自定义版本的 CLR,可以改善调试体验。
回答by Darin Dimitrov
回答by Eric Dahlvang
It's explained here in MSDN: Debugging and the Hosting Process.
MSDN: Debugging and the Hosting Process中对此进行了解释。

