Questions about "vshost" files

by Victor 15. September 2009 05:38

Here are some common questions about the vshost file:

What is vshost.exe file and what is that for?

Vshost file is the hosting process file. Microsoft introduced this from Visual Studio 2005. It has three main purposes.
1. Improve the performance for debugging. 
Managed code need to run inside application domains which provide isolation, unloading, and security boundaries for executing managed code. But it takes some time to create an AppDomain and initialize the debugger along with it. When your application end, the AppDomain and debug state will get lost. When you debug your code, you need to do it over and over again. It becomes not ideal at all. So the job of the hosting process is to improve performance by handling creation of the AppDomain and the initialization of the debugger at the background before you start debugging and keep the state around between runs of your application.
2. Allow partial trust debugging.
From Visual Studio 2005, you have the ability to debug applications in partial trust with permission settings as defined on the new Security page. When you deploy a partial trust application, it runs in a limited security context automatically. However, simulating a partial trust environment within Visual Studio under the debugger requires special initialization of the AppDomain, which is handled by the hosting process.
3.Allow design time expression evaluation.
The hosting process gives you the ability to test code in your application from the immediate window, without actually having to run your application. The hosting process is also used to execute your code under design time expression evaluation.

Why it is in the "Bin" folder?

When your application is run within the hosting process "vshost" is the top level executing assembly in the AppDomain, not your application. Therefore assemblies, config files, and manifest files cannot be properly loaded in all scenarios unless the "vshost" files are in the same folder with all of the other files.

Can I remove the "vshost" file from the release build?

Yes, you can. The *.vshost.exe file are only needed by visual studio IDE. They do not have any other usage.

How to stop generating "vshost" files?

It very simple to stop generating "vshost" files. In the project's property page, you need to change the configuration to be release.  And in the enable debuggers section untick the option "Enable the Visual Studio hosting process".


 

Tags:

Technology | Programming

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar

Month List