496

When I create and compile a "Hello, World!" application in C#, I get three files in the Debug folder apart from the main exe (e.g. HelloWorld.exe)

  1. HelloWorld.vshost.exe
  2. HelloWorld.pdb
  3. HelloWorld.vshost.exe.manifest

What purpose do these files serve?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Milen
  • 5,553
  • 5
  • 21
  • 12

6 Answers6

419

The vshost.exe feature was introduced with Visual Studio 2005 (to answer your comment).

The purpose of it is mostly to make debugging launch quicker - basically there's already a process with the framework running, just ready to load your application as soon as you want it to.

See this MSDN article and this blog post for more information.

Callum Watkins
  • 2,844
  • 4
  • 29
  • 49
Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • 29
    So is that the reason why when I run Console.Write(System.AppDomain.CurrentDomain.FriendlyName) from the debugger, I get app.vshost.exe and when I run directly from the exe I get output as app.exe – Milen Apr 21 '09 at 20:07
  • @Milen, http://msdn.microsoft.com/en-us/library/ms242202.aspx mentioned the different result of AppDomain.CurrentDomain.FriendlyName with and without host process. – Thomson Aug 14 '14 at 09:43
  • 2
    If vschost and .pdb files exist for debugging purposes, then why are they still included when I compile in Release? – John Smith Aug 08 '16 at 21:39
  • 2
    I guess they removed it in Visual Studio 2017 – Felipe Pessoto Dec 25 '16 at 12:51
177
  • .exe - the 'normal' executable

  • .vshost.exe - a special version of the executable to aid debuging; see MSDN for details

  • .pdb - the Program Data Base with debug symbols

  • .vshost.exe.manifest - a kind of configuration file containing mostly dependencies on libraries

Daniel Brückner
  • 59,031
  • 16
  • 99
  • 143
65

The vshost.exe file is the executable run by Visual Studio (Visual Studio host executable). This is the executable that links to Visual Studio and improves debugging.

When you're distributing your application to others, you do not use the vshost.exe or .pdb (debug database) files.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Will Eddins
  • 13,628
  • 5
  • 51
  • 85
  • I remember we didn't have such an executable in VS2003 (yet we did have breakpoints). Can you elaborate on that? – Mehrdad Afshari Apr 21 '09 at 19:28
  • 1
    Furthermore, the manifest is metadata about the application which usually also gets linked into the executable. The .pdb file is a Portable Debug Database and contains debug information about the compiled executable, like which point in the executable corresponds to which line in code. – Joey Apr 21 '09 at 19:29
  • 3
    The VS host process is only used to improve debuging - but it does not enable debuging. – Daniel Brückner Apr 21 '09 at 19:42
25

Adding on, you can turn off the creation of vshost files for your Release build configuration and have it enabled for Debug.

Steps

  • Project Properties > Debug > Configuration (Release) > Disable the Visual Studio hosting process
  • Project Properties > Debug > Configuration (Debug) > Enable the Visual Studio hosting process

Screenshot from VS2010

Reference

  1. MSDN How to: Disable the Hosting Process
  2. MSDN Hosting Process (vshost.exe)

Excerpt from MSDN How to: Disable the Hosting Process

Calls to certain APIs can be affected when the hosting process is enabled. In these cases, it is necessary to disable the hosting process to return the correct results.

To disable the hosting process

  1. Open an executable project in Visual Studio. Projects that do not produce executables (for example, class library or service projects) do not have this option.
  2. On the Project menu, click Properties.
  3. Click the Debug tab.
  4. Clear the Enable the Visual Studio hosting process check box.

When the hosting process is disabled, several debugging features are unavailable or experience decreased performance. For more information, see Debugging and the Hosting Process.

In general, when the hosting process is disabled:

  • The time needed to begin debugging .NET Framework applications increases.
  • Design-time expression evaluation is unavailable.
  • Partial trust debugging is unavailable.
SimplyInk
  • 5,832
  • 1
  • 18
  • 27
11

I'm not sure, but I believe it is a debugging optimization. However, I usually turn it off (see Debug properties for the project) and I don't notice any slowdown and I see no limitations when it comes to debugging.

Brian Rasmussen
  • 114,645
  • 34
  • 221
  • 317
  • What is "Guard"? Reference to a user with one of the answers here? Something else? Can you update your answer (e.g. with a direct link, as user names can change at any time)? – Peter Mortensen Jan 03 '20 at 12:25
  • I think this was a reference to another answer, but this was in 09 so forgive me if I don't remember the details. – Brian Rasmussen Jan 06 '20 at 06:37
2

It seems to be a long-running framework process for debugging (to decrease load times?). I discovered that when you start your application twice from the debugger often the same vshost.exe process will be used. It just unloads all user-loaded DLLs first. This does odd things if you are fooling around with API hooks from managed processes.

Joshua
  • 40,822
  • 8
  • 72
  • 132
  • 1
    The persistent process also causes exception (access violation) when my project has some code to do P/Invoke. The problem disappeared after I disabled host process. – Thomson Aug 14 '14 at 09:38