Why I am right!

May 22, 2008

Debugging "caught" Exceptions

Filed under: Debugging, Microsoft, Technology, Visual Studio — Shaun @ 10:05 pm

For the past week or so I noticed a few strange entries in the Visual Studio “Output” window when debugging to a certain page of our app.

Overflow

Something on my page is throwing and catching an OverflowException. Now it probably didn’t matter what was causing this exception because the application was working fine but sometimes things like this bother me enough that I have to figure it out. Luckily there is an easy way to debug ANY exception that you see in that window. I found the solution here.

Once I setup Visual Studio to catch all exceptions of type System.OverflowException (by following the steps in the linked article) the debugger popped the following window anytime that exception was thrown.

  Overflow

From here I was able to follow the stack trace to debug the actual problem which was an Integer getting set incorrectly in a grid we use.

January 18, 2008

Changing the diff/merge program used by Visual Studio

Filed under: Beyond Compare, Microsoft, Technology, Visual Studio — Shaun @ 9:42 pm

I first want to congratulate Microsoft on releasing a diff tool that is significantly better than any of their previous versions. I would also like to thank the developers for giving us a way to change the default tool to something else.

Personally I prefer using Beyond Compare. There are a number of reasons why I like it better but in the end it just comes down to what you are familiar with and personal preference. If you are still stuck in the stone age using tools like WinDiff, SourceSafe give it a try, it is free for 30 days.

Anyway, here is how you change the default diff/merge tool in Visual Studio. I know this works in 2005 and 2008. From what I recall the menus are pretty similar in each version.

  • Open Visual Studio
  • Click Tools.. Options
  • Select Source Control in the left pane. (If it is not there check the “Show all settings” box at the bottom left.
  • Select Visual Studio Team Foundation Server.
  • Click the “Configure User Tools” button in the right pane.

Options

  • Click Add in the “Configure User Tools” window

Add

Now you are ready to enter the configuration for whichever tool you choose to use. Below is what I entered for Beyond Compare.

Compare Settings:

%1 %2 /title1=%6 /title2=%7

BeyondCompare

Merge Settings:

%1 %2 /savetarget=%4 /title1=%6 /title2=%7

Merge Settings

If you are not using Beyond Compare here is a post by James Manning that lists settings for different compare and merge tools including WinDiff!

 UPDATE (2/20/08): Added Merge settings

December 20, 2007

ASP.Net Edit and Continue in Visual Studio 2005/2008

Filed under: ASP.Net, Edit and Continue, Microsoft, Technology, Visual Studio — Shaun @ 4:20 pm

I have seen many articles that said Edit and Continue does not work in ASP.Net for Visual Studio 2005. Well, it works for me and here is how to enable it. I have showed many people how to enable this and every time I show someone I have to figure it out again. So I am putting this out there to hopefully save someone else the frustration.

To enable Edit and Continue there are 2 separate setting. The first is under Tools.. Options. Open the Debug section of the tree and click on the Edit and Continue Group. Make sure “Enable Edit and Continue” is checked. If you are using the VS 2005 Professional you may need to click a checkbox at the bottom of this screen saying something like Show all Options.

Options

The second setting is in a strange place. I am not sure if this works with the new Web Projects introduced in 2005. We are using the Visual Studio 2005 Web Application Project which may have something to do with it. Open up the solution you are attempting to debug, right click on the web project, and click Properties. When the property window opens click down to the “Web”. Check the Enable Edit and Continue box and you should be all set.

ProjectSettings

I will never understand why there are two places you have to enable this, but at least it works.

UPDATE: You must be at a break point in your code to edit. You cannot edit method signatures, add new methods, etc. Changes like that were not what Edit and Continue were designed for and I can’t even start to think how that would be implemented by Microsoft.

UPDATE (again): I recently started working with Visual Studio 2008. This fix applies to that version as well.

Blog at WordPress.com.