Friday, September 30, 2005

Some devstudio tips

Hi everyone,

I sent this around at work yesterday. Its just a couple of tips about programming in Visual Studio .Net 2003.

When a project changes, dev studio offers to Reload it. This doesn't always work.

1. Most of the time the Reload button works fine when a vcproj or sln file has changed. However, in the case where a new file has been added to the project you will usually find that you have to completely close out the solution and then load it again to avoid link errors for code in the new file. Personally, I just restart dev studio in such cases.

Setting up Tool menu items to run perforce commands

2. To properly set up the Tools menu to have your perforce checkin, checkout, revert, and sync commands you need to set the following environment variable: "P4CLIENT=username". For example, I have set my P4CLIENT environment variable to "mmoore". Then you can set up commands like "c:program files\perforce\p4.exe" with arguments "diff -f $(ItemPath)". If you have logged in to perforce via p4win, you should have no problems. To be safe, I also set : "P4PORT=myperforceserver:1666", but I'm not sure if you need that.

Properly handling an environment variable change

3. Note that when you make changes to environment vairables via

"My Computer/Properties/Advanced/Environment Variables...",

you are not going to see those changes in any programs that were already running prior to that point. This can bite you in many ways, but one of the more apropos in this case is the need to restart devstudio after changing an environment variable, such as the P4CLIENT mentioned above.

* SIDE NOTE: Those who might use a filebrowser program instead of the default explorer folder browsers have to be especially cautious on the environment variable changes. If you're used to running devstudio from Directory OPUS or Explorer XP and you change an environment variable to a new value in the windows shell, you'll need to restart your file browser program so that new programs launched with inherit the updates to the environment variables.


4. Devstudio added minidumps to the mix in 7.0, which makes it easy to set up a crash handler that takes a snapshot of the stack, registers, and associated information such that the call stack can be reproduced faithfully at any time in the future. A minidump may decide to include the entire heap if desired - doing so allows you to view all aspects of memory including the values of variables not on the stack. Heap minidumps also do not need to be pointed to the original binary to load symbols - the heap info is enough. Minidumps without the heap, on the other hand, must be pointed to the original binary and its associated pdb file.

To use a minidump, you simply open it in devstudio and open it as if it were a project file. You'll see a callstack as if the program had just crashed, though of course it hasn't. :)

Hope these tips help somebody,


1 comment:

Leo said...

I found this old post randomly while searching. :) Just thought I'd comment (in case someone else finds it) that there's no need to restart Directory Opus to pick up env-var changes. It does so automatically now.

(Maybe it didn't back in 2005. Not sure.)