banner
Dave Horner's Website - Yet another perspective on things...
Home Tech Talk Programming Visual Studio Tips and Tricks
$$\cos x = \sum\limits_{n = 0}^\infty {\frac{{\left( { - 1} \right)^n x^{2n} }}{{\left( {2n} \right)!}}}$$

Who's Online

We have 58 guests online
Content View Hits : 1608596
moon and stars
default
(*-*)
How did you find my site?





 
How often do you answer random online questions?


 

Random Quote

Save the whales. Feed the hungry. Free the mallocs.
— fortune(6)

Visual Studio Tips and Tricks

Wednesday, 06 September 2006 15:15
Visual Studio is something that I've had to deal with for a long time in my life so I have a love/hate relationship with it.

Versions of Visual Studio

Visual C++ 6    = VC6 = _MSC_VER 1200
VS 2003 = = VS7 = VC7 = _MSC_VER 1300
VS 2005 = = VS8 = VC8 = _MSC_VER 1400
VS 2008 = = VS9 = VC9 = _MSC_VER 1500
VS 2010 = = VS10 =VC10= _MSC_VER 1600
VS 2012 = = VS12 =VC12= _MSC_VER 1700
VS 2013 = = VS13 =VC13= _MSC_VER 1800
C++11 Features in Visual C++ 11 - Visual C++ Team Blog - Site Home - MSDN Blogs


Visual Studio 2013, .net 4.5.1, VS2013

C++ Conformance Roadmap - Somasegar's blog - Site Home - MSDN Blogs - "the RTM version will also include a few tactical C99 language extensions when compiling C code, so that some popular community libraries (including FFmpeg) will now be able to compile with Visual C++ 2013."!!!
What’s New for Visual C++ Developers in VS2013 Preview - Visual C++ Team Blog - Site Home - MSDN Blogs
ATL and MFC changes and fixes in Visual Studio 2013 - Visual C++ Team Blog - Site Home - MSDN Blogs - no atl dll, a single static atl!


Visual Studio 2010, .net 4.0

Look at all the testing tools! :) Exciting stuff indeed.
Visual Studio 2010 and .NET Framework 4.0 Overview
Download details: Visual Studio 2010 and .NET Framework 4 Training Kit
10-4 | Shows | Channel 9 - channel 9 videos on 2010 features.
WCF / WF 4 Training Kit - Home
Download details: WCF WF Samples for .NET Framework 4.0 Beta 1
A quick analyze of the .NET Fx v4.0 Beta1 - Patrick Smacchia [MVP C#]
Download details: Visual Studio 2010 and .NET Framework 4 Training Kit
VCBuild vs. C++ MSBuild on the Command Line - Visual C++ Team Blog - Site Home - MSDN Blogs - they took eer vcbuild...


Visual Studio 2008, .net 3.5, sqlcompact

Download details: Visual Studio 2008 Service Pack 1 Beta
Download details: .NET Framework 3.5 Service pack 1 Beta
Download details: SQL Server Compact 3.5 SP1 Beta for ADO.Net Entity Framework Beta 3
Visual Studio 2008 (vs2008), includes a lot of new tools for working with XML, XTDs, XSD, etc. New XML editors with intellisense and XML schema explorer let you navigate and code with ease. Glad to see this come in the product.
CoDe Magazine - Article: XML Tools in Visual Studio 2008

Web Resources

Eric Nelson - Development for .NET Framework for ISVs : Visual Studio 2008 Training Kit updated for RTM
Boris Jabes's Webblog (VS Program Manager)
Visual Studio 2005 Service Pack 1 Beta
Debugging in Visual Studio: Avoid Stepping Into Common Functions
EEAddIn Sample: Debugging Expression Evaluator Add-In
dzolee's pocketblog: Remote debugging
How to Not Step Into Functions using the Visual C++ Debugger
Automatically Obtaining Source and Line Number from Symbol Name and Offset - All Your Base Are Belong To Us - goldshtn/offset2source - A tool that converts module (and optional method) instruction offsets back to the .cpp source file and line number.
Random ASCII | Forecast for randomascii: programming, tech topics, with a chance of unicycling

Formatting variables within the IDE

VS2005 has gotten a lot better when it comes to displaying custom datatypes within the IDE. There is a file called autoexp.dat which controls the formatting of datatypes within the VS watch and tooltip windows. This is the file that provides the expansion for types like CStrings, std::vectors, std::string, etc. Just edit autoexp.dat to provide the expression expansion for your custom type. (This came up for me because I was always dealing with a custom string class that subclasses the std::string and as tired of having to expand the class to view the std:string)
Full path to autoexp.dat is: "C:\Program Files\Microsoft Visual Studio 8\Common7\Packages\Debugger\autoexp.dat"
The following link provides more information on the constructs within the autoexp.dat file.
Writing custom visualizers for Visual Studio 2005
Wow, custom debugger visualizers allow you to display custom binary data using your own custom drawing methods. Instead of seeing dec/hex representations of image data, you can actually view it. How cool!
Create a Debugger Visualizer in 10 Lines of Code

Compile problems relating to C++ code generation

Why is code generation so hard in Visual Studio? Why can't the linker tell me which libraries are mis-matched runtime? Instead Visual Studio chooses to give me all these warnings about things being defined multiple times. And many people simply choose to ignore libraries to get it to build. But this is *NOT* the solution!

Use the following command to figure out what version of the C runtime you are using:
dumpbin /directives somefile.obj

Native code deployment

Until VS2005, native code deployment was pretty clean. You could compile a small native executable and it didn't require a redistributable package to run. This is a painful additional installation requirement...the same pain as managed code deployment.
Download details: Visual C++ 2005 Redistributable Package (x86)
Download details: Visual C++ 2008 Redistributable Package (x86)
Deployment of your output executables from VS2005 can be a real headache. However, after about 2 weeks of playing I've finally decoded the steps to actually deploy a native C++ binary with /MD code generation. First, you can try doing a "private assembly" deployment by copying the required assembly from "Program Files\Microsoft Visual Studio 8\VC\Redist" to your executable's directory. This is nice because it means your user doesn't have to run (vcredist_x86.exe) which requires windows installer.

The other option is to use the vcredist_x86.exe which installs the needed shared side-by-side assemblies into the native assembly cache (WinSxS folder). Microsoft provides a download for vcredist_x86.exe but I've never gotten it to work (likely because my CRT version isn't the same...VS2005 SP1). It is always best to grab your vcredist_x86.exe directly from the "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\vcredist_x86" folder.

Links to more detailed information about using the VC runtime files in VS 2005 SP1
Visual Studio 2005 DLL Hell
MSDN Forums/Re: msvcr80.dll not found
Run-Time Library Reference
Confusion: Libraries, .lib and .DLL
Visual C++ Libraries as Shared Side-by-Side Assemblies
Troubleshooting C/C++ Isolated Applications and Side-by-side Assemblies
Q&A on adapting VS2005 SP1 to build your applications
How to perform a silent install of the Visual C++ 8.0 runtime files (vcredist) packages
_USE_RTM_VERSION (flag to build native code without SP1 redist)
Private deployment of runtime in mixed RTM and SP1 environment

Project/solution converters and tools

Using VS2005 to develop build v1.1 projects
VC++7 to VC++6 project converter
vctool - dumps the basic skeleton of either '.dsp' or '.vcproj' project files used by MS Visual Studio
Creating a C++ Project from a PDB file: PDB Project [[Version 2.0]] - Visual C++ Team Blog - Site Home - MSDN Blogs - pdb's aren't just for debuggin.

Plugins

Versioning Controlled Build
Build Number Automation for Visual Studio .NET Projects
Building a Refactoring Plug-in for VS.NET - the Sequel
jens-schaller.de: SonicFileFinder - find files within a solution easy. (a vs2005/vs2008 plugin)
brunomlopes-visualstudioplugins - Google Code - includes a cullwindows plugin to keep your open tabs under control.


Misc

The Road to MSBuild
How to upgrade VS2003 projects to VS2005
VS 2005 - Inferior to VS 2003?
Ask The Pros: Keyboard Bashing With The Pros
Larry Osterman's WebLog - Building a Project from the Command Line


Team Foundation

Download details: Visual Studio Team System 2008 Team Explorer
Download details: Team Foundation Power Tools
patterns & practices: Team Development with Visual Studio Team Foundation Server - Home
James Manning's blog : diff/merge configuration in Team Foundation - common Command and Argument values
Team Individualism : Team Foundation Server Tools
Visual Studio Team Foundation Server MSSCCI Provider - provides team foundataion source control access from VS2003.
Download details: Visual Studio Team Foundation Server MSSCCI Provider
patterns & practices: Team Development with Visual Studio Team Foundation Server - Release: Team Development with TFS - Final Release - guidance.
Rory Primrose | Using WinMerge with TFS

Team Foundation Server SDK

Aaron Hallberg : Team Build API: GetBuildUri and GetBuildDetails
TFS API Examples - TFS API Examples
Mohamed Mahmoud (El-Geish) : How to: Diff files using TFS APIs?
James Manning's blog : programmatically showing differences between files - you'll need the link below to find Microsoft.TeamFoundation.VersionControl.Common.
Buck Hodges : How to add the Team Foundation assemblies to the .NET tab in the VS Add Reference dialog
Ed Hintz (MSFT) : How to Write a Team Foundation Version Control Add-in for Visual Studio
CodeProject: TFS Event Handler in .NET 3.5 Part 2 - Handling Team Foundation Server Events.

Addins

Visual Studio Gallery | PowerCommands for Visual Studio 2008
A Custom Action for Deploying Visual Studio 2005 Add-in - The Code Project - Installation
How to: Deactivate and Remove an Add-in
CoDe Magazine - Article: Creating Visual Studio Add-Ins
Update Visual Studio 2005 Add-ins for Visual Studio 2008 - Keyvan Nayyeri
Mole v4.1 For Visual Studio « Karl On WPF - .Net


Visual Studio for Applications (VSA) is the replacement for the old scripting tech. called VBA. In VBA, the application model was exposed via OLE Automation. In VSA, the application model is exposed via the .NET Framework. VSA can use either VB or C# for scripting. Very nice automation for the managed world. It installs from the Visual Studio SDK.
Introducing Visual Studio for Applications
MSDN blog - Visual Studio Tools for Applications


VS2008

Visual studio 2008 has been released! It comes with a lot of great new functionality.
Download details: Visual C++ 2008 Feature Pack
Visual Studio 2008 and .NET 3.5 Released - ScottGu's Blog - an overview of new things that are available with VS2008
Steps to Uninstall VS 2008 Beta2 before installing the VS 2008 Final Release - ScottGu's Blog


MSBuild

MSBuild Team Blog
MSBuild Community Tasks Project - an open source project for MSBuild tasks. The goal of the project is to provide a collection of open source tasks for MSBuild.
MSBuild - What It Does and What You Can Expect in the Future @ .NET DEVELOPER'S JOURNAL
Attrice Corporation MSBuild Sidekick v2 ($)
Visual Debugger for MSBuild Projects - Home
Visual C++ Team Blog : Using different toolsets for vc build
XmlLogger for MSBuild
automate devenv /upgrade
Inside MSBuild: Compile Apps Your Way With Custom Tasks For The Microsoft Build Engine -- MSDN Magazine, June 2006
Jomo Fisher -- C#, LINQ and Whatnot : Hack the Build: Programmatically Converting Older VS .NET Projects to MSBuild
Jomo Fisher -- C#, LINQ and Whatnot : Hack the Build: Cracking MSBuild Project Files


Synchronize the Currently Open File with Solution Explorer

For some reason this is not the default, but it really should be. There are many contextual menus possible in the solution explorer(esp. with TFS)...now instead of having to search yourself, VS will update the treeview as you change textfiles. Nice.
The option for auto-sync is:
Tools|Options|Projects and Solutions|General|Track Active Item in Solution Explorer


Changing the look and feel of Visual Studio

Sometimes it is nice to change the look of the code with which you work. I'm not the most talented in terms of selecting colors, but there are templates available... :)
Join the Dark Side of Visual Studio - Infinities Loop
Scott Hanselman's Computer Zen - Visual Studio Programmer Themes Gallery


Navigating large projects in visual studio

Tools > Options > Projects and Solutions > Track Active Item in Solution Explorer
I don't know why this option isn't on by default. I find it hard to work in large solutions without it.


namespace name 'TeamFoundation' does not exist in the namespace 'Microsoft'

This is an interesting problem. I found this while trying to build Scrum Sprint Monitor - Source Code, looks like to make it work you've gotta install the team foundation client.


Visual studio hotkeys

Ctrl+F12
Edit.GoToDeclaration
F12
Edit.GoToDefinition
Shift+F12
Edit.FindAllReferences
Ctrl+-
View.NavigateBackward
Ctrl+Shift+-
View.NavigateForward
Ctrl+G
Edit.GoTo


Debug mode fill constants

Memory Management and the Debug Heap
c++ - When and why will an OS initialise memory to 0xCD, 0xDD, etc. on malloc/free/new/delete? - Stack Overflow
  • NoMansLand (0xFD) -
    The "NoMansLand" buffers on either side of the memory used by an application are currently filled with 0xFD.
  • Freed blocks (0xDD)
    The freed blocks kept unused in the debug heap's linked list when the _CRTDBG_DELAY_FREE_MEM_DF flag is set are currently filled with 0xDD.
  • New objects (0xCD)
    New objects are filled with 0xCD when they are allocated.
  • 0xCC
    When the code is compiled with the /GZ option, uninitialized variables are automatically assigned to this value (at byte level).
  • 0xAB (Allocated Block?) Memory allocated by LocalAlloc().
  • 0xBAADF00D Bad Food Memory allocated by LocalAlloc() with LMEM_FIXED,but not yet written to.
  • 0xFEEEFEEE OS fill heap memory, which was marked for usage, but wasn't allocated by HeapAlloc() or LocalAlloc(). Or that memory just has been freed by HeapFree().
Debugging Heap corruption with Application Verifier and Debugdiag - IIS debugging and debugdiag - Site Home - MSDN Blogs
Download: Debug Diagnostic Tool v1.2 - Microsoft Download Center - Download Details

Why are my debug builds so slow?

In VC10, they're controlled by the macro _ITERATOR_DEBUG_LEVEL, which supersedes VC8 and VC9's more confusing _SECURE_SCL and _HAS_ITERATOR_DEBUGGING macros.
_ITERATOR_DEBUG_LEVEL - Advanced STL, Part 3 - Visual C++ Team Blog - Site Home - MSDN Blogs
C9 Lectures: Stephan T. Lavavej - Standard Template Library (STL), 1 of n | Going Deep | Channel 9
Win32 Debug CRT Heap Internals
The [no_sillywarnings_please.h] file | Alf on programming (mostly C++)


Image File Execution Options, and debugging

Did you know about "Image File Execution Options"? How to: Launch the Debugger Automatically A very useful feature within the windows OS. It is a way determine when a dll/module is loaded or attach a debugger to a process at startup that is started outside a debugger. Inside 'Image File Execution Options' debugging - greggm's WebLog - Site Home - MSDN Blogs
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\
;64-bit Windows
HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\
Force a break while debugging when a dll/module is loaded
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\<modulename.dll>]
"BreakOnDllLoad"=dword:00000001
Force a process to start under the Visual Studio Debugger
adding a string value called "Debugger" allows you to run whatever you like, instead of the direct executable the user requested. Scary, I know.
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\<processname.exe>]
"Debugger"="vsjitdebugger.exe"


above two suggestions come from Image File Execution Options - Wes' Puzzling Blog.
Two Minute Drill: Configuring a Debugger using Image File Execution Options - Ask the Performance Team - Site Home - TechNet Blogs
Junfeng - Image File Execution Options
Greggm - Breaking when a module loads
Greggm - Inside 'Image File Execution Options' debugging
Oldnewthing - Beware the Image File Execution Options key
“Image File Execution Options” is an Evil Registry Key | TrojanHunter Blog
A Debugging Approach to IFEO - Rubato and Chord - Site Home - MSDN Blogs


Autoruns for Windows - autoruns shows you in the "Image Hijacks" tab.

Procdump via IFEO

Procdump via Image File Execution Option - Sysinternals Forums
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe]
"Debugger"="c:\\notepaddump.bat"
REM notepaddump.bat
procdump.exe /accepteula -ma -c 20 -s 5 -x %1 c:\notepad.dmp %2 %3 %4 %5 %6 %7

Replace notepad.exe the safer way

just placed here because the safer method uses IFEO
Replace Notepad with Notepad++ in W7 | Binarycore - example vbs script that tunnels the command line args into notepad++, issue with this being that most user's can't write to programfiles.


Debugging tips and tricks, WinDBG & friends

Rubato and Chord - Site Home - MSDN Blogs - reiley's site is great.
Early Debugging - Rubato and Chord - Site Home - MSDN Blogs
Undocumented WinDBG - Rubato and Chord - Site Home - MSDN Blogs
Undocumented Environment Variables - Rubato and Chord - Site Home - MSDN Blogs - oh there must be more variables in the ENV, let me go grab my WinDBG...
Turning off filename and line number display in the debugger » bits and bytes - in WinDbg, this option is on by default. In CDB and KD, the -lines command-line option will turn this option on.
NonInvasive debugging » bits and bytes - The debugger suspends all threads in the process and has access to all threads, memory and register’s of the process.
Automatically launching CDB to take a dump of a native/managed crash » bits and bytes
How to list out binaries for which symbol loading failed » bits and bytes
How to force symbol loading in WinDbg » bits and bytes

< Prev  Next >
Last Updated on Saturday, 12 April 2014 04:43