What is the purpose of the vshost.exe file?
Asked Answered
E

6

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?

Eiten answered 21/4, 2009 at 19:24 Comment(0)
C
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.

Credulous answered 21/4, 2009 at 19:30 Comment(4)
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.exeEiten
@Milen, msdn.microsoft.com/en-us/library/ms242202.aspx mentioned the different result of AppDomain.CurrentDomain.FriendlyName with and without host process.Tannie
If vschost and .pdb files exist for debugging purposes, then why are they still included when I compile in Release?Enclitic
I guess they removed it in Visual Studio 2017Lecherous
G
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

Guttersnipe answered 21/4, 2009 at 19:31 Comment(0)
G
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.

Gev answered 21/4, 2009 at 19:28 Comment(3)
I remember we didn't have such an executable in VS2003 (yet we did have breakpoints). Can you elaborate on that?Intort
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.Unfair
The VS host process is only used to improve debuging - but it does not enable debuging.Playroom
I
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.
Imbecilic answered 17/5, 2017 at 3:26 Comment(0)
B
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.

Bobbinet answered 21/4, 2009 at 19:33 Comment(2)
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)?Link
I think this was a reference to another answer, but this was in 09 so forgive me if I don't remember the details.Bobbinet
T
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.

Towland answered 10/9, 2009 at 4:8 Comment(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.Tannie

© 2022 - 2024 — McMap. All rights reserved.