Microsoft 9GD00001 Computer Accessories User Manual


 
154 Microsoft Visual Studio 2010: A Beginner’s Guide
window specifies the location of the executable file of the program to be debugged, that
the output folder is shared, and that your application has permissions on the shared folder.
The focus of this book is on managed code, which runs on the .NET CLR.
VS has the
ability to debug unmanaged code, such as that written in C++ that communicates directly
with the operating system. Generally, you want to leave the Enable Managed Code
Debugging box unchecked unless you are writing managed code that interoperates with
unmanaged code, such as a COM DLL library, and need the ability to debug both. VS will
allow you to open SQL Server stored procedures, set a breakpoint, and step through the
stored proc code for debugging. If you need to debug stored procedures, make sure you
check this box.
NOTE
Managed code refers to code that runs on the .NET Common Language Runtime
(CLR). The CLR is a virtual machine that provides several services such as memory
management, code execution, garbage collection, security, and more. In contrast to
managed code, there is also code that is called unmanaged code. Unmanaged code
does not use the .NET CLR; instead it runs directly on the computer and communicates
with the operating system. With unmanaged code, you must manage your own memory
and write low-level code to accommodate all of the services that the CLR would normally
give you. You can use VS to write unmanaged code in C++, but this book focuses on
C# and VB, which produce executable files that run managed code on the CLR.
The Enable The Visual Studio Hosting Process setting is what caused the vshost files
to be generated in the output folder. Normally, you want to leave this box checked because
of the benefits of vshosts, described previously. The only exception might be if you had
a unique situation where the services provided by the vshosts process conflicted with the
code you were running, which would be an advanced and rare scenario.
TIP
In earlier versions of VS, you would occasionally get a file permission error on the
vshosts file, which was caused by the fact that there were file locks on the file. This
can occur if you have attached to the running process from another instance of VS
or the process shut down improperly in a sequence that didn’t release the file lock on
vshosts. One of the work-arounds is to uncheck the Enable The Visual Studio Hosting
Process box, rebuild, recheck the Enable The Visual Studio Hosting Process box, and
build again. You also have the choice of restarting your OS, whichever you find easier.
This scenario doesn’t point to a deficiency in VS or the operating system, because
the file locks are necessary when an application is running. Rather, the scenario is a
consequence of having a bug in your code or improperly shutting down an application.
In addition to property settings, you have a plethora of options available via the Options
window, which you can open by selecting Tools | Options, as shown in Figure 6-5.