VSHOST — the Hosting Process

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!

Comments (13)

  1. If you’re running Whidbey, you may have noticed that when you debug a Windows app that you see two entries in your Task Manager. One for the application, and one for something called VSHOST (it’ll show up as .vshost.exe). VSHOST…

  2. Jasper22 says:

    Visual Studio could not copy a support file to this location:

    ‘V:<app name>#Debug<app name>.vhost.exe’. Please verify that path exist and is writeable.

    What the heck is this error ?

  3. Check the vshost.exe file at the specific location in the error. It’s probably locked and in use.

    There are several possible causes for this – you may have selected Detach during a debugging session, there may be an orphaned vshost.exe process running (if VS crashed and didn’t get a chance to shut it down), etc.

    You’ll need to close the project and then use Task Manager to end process any corresponding <projectname>.vshost.exe processes that are still running.

    Visual Studio attempts to copy the vshost.exe file to the bin directory after a project is opened to make sure the right version of the file is in the bin directory (we have 2 versions – a neutral assembly and a 32 bit only version used for 64 bit scenarios). We do this copy to ensure that the one in the bin diretory matches the platform specified in the project file.

    We have a fix being added to make the copy requirement less restrictive in the future.

  4. Feedback request explained…

  5. Anonymous says:

    Oliver Sturm’s weblog – AppDomain.FriendlyName and vshost

  6. jokiz says:

    i was surprised to see two new files in the bin folder of our windows application project (&lt;application

Skip to main content