If you have been using the new Visual Studio 2005 beta you have noticed a few new files showing up in the "bin" folder with the word "vshost" in the filename. For example, when you create a new WindowsApplication and hit F5, you may notice files named "WindowsApplication1.vshost.exe" and "WindowsApplication1.vshost.exe.config". This post is intended to shed some light on the reason why these new files exist, and answer a few common questions that people have been asking about them.

What is "vshost"?

This is the "hosting process". It is created whenever you build a project in the Visual Studio 2005 IDE. Its purpose is to provide support for improved F5 performance, partial trust debugging, and design time expression evaluation.

Improved F5 performance. As everyone knows, when you hit F5 your program is run. However, running a managed application requires the creation of something called an "AppDomain", which houses the runtime environment within which your application runs. It actually takes quite a bit of time to create an AppDomain and initialize the debugger along with it. This introduces a lag which is particularly noticeable when you are doing it over and over again. The problem is exacerbated by the fact that when your application ends, all of the AppDomain and debugger state is lost. When you hit F5 again, everything must be created and initialized again. The hosting process speeds up this process by doing all of this work in the background before you hit F5, and keeping the state around between runs of your application.

Partial trust debugging. A new feature in Visual Studio 2005 is 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.

Design time expression evaluation. Another new feature in Visual Studio 2005 is 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.

What's it doing in my "bin" folder?

There are numerous technical reasons why the "vshost" files must be in the same folder as your program. 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 ClickOnce and side-by-side manifests cannot be properly loaded in all scenarios unless the "vshost" files are in the same folder with all of the other files.

Should I deploy the "vshost" files with my application?

No. The "*.vshost.exe" and "*.vshost.exe.config" files are only for use in the Visual Studio 2005 IDE. They should never be run directly, and they shouldn't be deployed with your application.

Can I disable generation of "vshost" files?

In Beta1 this feature is always enabled for all "Windows" application project types. In Beta2 we do plan to add an option to disable this functionality, but of course you would then loose the benefits outlined above. If you are experiencing a problem in the beta that you think may be related to this feature, please report a bug!