Tag Archives: visual studio

log4cxx + VS2005 + Windows SDK v6.0 = compile error

If you are following the instructions to build log4cxx 0.10 in Visual Studio 2005, and you have the Windows Platform SDK v6.0 installed, you may get errors compiling multicast.c in the apr project.

I found the solution, and it’s pretty easy. Open up multicast.c and edit the lines:

136: #if MCAST_JOIN_SOURCE_GROUP

148: #if MCAST_JOIN_SOURCE_GROUP

to be, instead:

136: #if defined(group_source_req)

148: #if defined(group_source_req)

 

e voilà! now it compiles.

Opening Visual Studio solutions from Explorer in Vista

You’ve installed Visual Studio 2005 on Vista and dutifully changed it to run as administrator, like you’re supposed to. And then…

Problem: Visual Studio 2005 solutions no longer open when you double-click them in Windows Vista. In fact, when you double-click nothing happens.

Solution: Change them to open with Visual Studio 2005 directly instead of the vslauncher.exe (which opens up the solution with the correct version of Visual Studio if you have more than one).

Caveat: Only makes sense if  you use only Visual Studio 2005.

How-to:

  1. Right-click on a solution file.
  2. Choose “Open With…”
  3. Choose “Browse…”
  4. Browse to file “C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe” (or wherever you installed Visual Studio)
  5. Click “Open” button
  6. Check “Always use the selected program to open this kind of file”

openwith

Now your solutions will load Visual Studio, bring up the UAC prompt, and it all works great.

Found via here and here.

Tip: Mouse back and forward work in Visual Studio 2005 too

You know how you can use the extra mouse buttons to move back and forward in Internet Explorer?

The same shortcuts work in Visual Studio. Suppose you right-click on a function call, and select Go To Definition. Once you’re done looking at the definition, hit the back button on your mouse: You’re taken right back to where you came from!

(The keyboard equivalents are Ctrl+ – and Ctrl+Shift+ -)

Technorati Tags:

A Visual Studio that’s easier on the eyes

After you’ve looked at Visual Studio all day for a few days in a row, the brightness of the white background can really start to bother you, especially as LCD monitors get brighter and brighter. That’s why I’ve become a big fan of Dave Reed’s Dark Side theme for Visual Studio 2005. It took me a few hours to get used to it, but now I’m hooked.

The only thing I changed was the font. I really like Consolas, size 13. Courier New is Courier-Old-and-No-Longer-Used.

At work, I still have to use VS2003 for a project, and keeping it in the older, white background really helps me distinguish which environment I’m in.

Visual Studio 2003 and 2005 Default Keyboard Shortcuts Cheat Sheet

My first book, C# 4.0 How-To is now shipping! If you like tips you can use, check it out!

I wanted to have a quick-reference sheet available to help me learn the Visual Studio keyboard commands. Surprisingly, I couldn’t find a handy printable reference. So I made one. It doesn’t contain ALL the shortcuts. For that, you can go to the online reference or this code that prints out all of your existing shortcuts.

If you just want a two-page reference sheet, handy to print front-to-back, to help you learn the shortcuts, download the PDF I created.

A screen shot of it…

Visual Studio 2003 & 2005 Default Keyboard Shortcuts Screenshot

A Debugging Exercise

A few weeks ago I had an interesting debugging problem. A program we develop had a memory leak in it that Visual Studio was catching when it ended. The trace text was something like this:

Detected memory leaks!
Dumping objects ->
{292300} normal block at 0x05590040, 2771928 bytes long.
Data: <> FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00
{292294} normal block at 0x05110040, 2613312 bytes long.
Data: <> FF FF FF 00 FF FF FF 00 FF FF FF 00 FF FF FF 00

Visual Studio 2003 is often pretty good at telling you where a memory leak occured, giving you a source code file and line number of where the memory allocation originated. In the case above, I don’t have that. There are two relatively easy ways of solving this.

The first method is to examine the data that isn’t being freed. In this case, I have two large objects of about 2.5 MB each. That’s pretty big–there aren’t too many (if any) individual objects in the software that are that large. So it could be an array. The data begins with a repeated pattern {FF FF FF 00}. Definitely looks like an array of 4-byte segments. Applying a little knowledge of the application itself–it displays large bitmaps–and we realize that the memory comes from an array of RGB values.

Another way to investigate this is to set a breakpoint on the memory allocation that isn’t being freed. The number in braces {292300} is the memory allocation number in debug mode in Visual C++. In order for this technique to work, you must first ensure that the number is the same each time. In my case, the memory leak would happen if I just opened and closed the program (because an image is always being drawn) without doing anything else.

First, set a breakpoint at the beginning of the program (or any place definitely before the memory leak). Start the program and when it breaks, enter the following into the watch window:

{,,msvcr71d.dll}_crtBreakAlloc

And for the value enter 292300.

If you continue the execution, the program will break on the 292,300th memory allocation. It will stop in the memory allocator, and you can then look at your stack frame and see exactly where the memory allocation is taking place.

MSDN has a great article about this.

In my problem it was for a set of memory blocks being used as working space for resizing and smoothing bitmaps. They were allocated once during execution and thus did not really provide a long-term threat. This leads to a possible third solution:

Ignore. All memory is reclaimed once the program exits. Nobody would ever do that, though…. would they?

…of course not…

Getting NUnit to work on .Net 2.0 and VS Studio 2005 Beta 2 (Whidbey)

I’ve been playing around VS.Net 2005 Beta 2 for a while now and like it so much that I’ve converted the BRayTracer to use it exclusively. Yes, this means you need .Net 2.0 to run all future versions, but it’s worth it.

I ran into the slight problem of not being able to use NUnit 2.2 with the latest .Net, but I found some help via google.

What worked for me specifically, was:

[code lang=”xml”]

[/code]

Of course, look in your C:\WINDOWS\Microsoft.NET\Framework folder to see what versions you have.

Visual Studio 2005 TS Beta 2

I finally received my Visual Studio 2005 Team System Beta 2 in the mail!

It took about 3 weeks to get here. I’m very excited. I plan on converting BRayTracer to use VS 2005.

It’s on track to take about 90 minutes to install. Installation of the compact framework failed, so I’m repairing that component. According to the log, it failed because another installation was in progress.

Features I’m looking forward to?

  • Refactoring – many free IDEs have them, it’s about time VS did too.
  • Improved IntelliSense – I know, IntelliSense is a crutch, but it’s a nice crutch to have–better than memorizing the API for Windows, .Net, MFC, and whatever sub-systems you’re working with.
  • The class designer – the old Add Method/Add Field was too slow and unwieldy to use.

There are a lot of other nice things that are in there. Check out the full list here.

Something I’d like to see that I don’t think is in there: change the type of a variable. I can foresee difficulties in this, but it would be a valuable feature.

[code lang=”cpp”]
float X;
[/code]

could be changed to

[code lang=”cpp”]
Coordinate X;
[/code]

and everywhere that variable is used, all the functions it gets passed to could be changed. As I said, there could be difficulties in this, but it would be powerful functionality.