Saturday, May 10, 2008

The evil sou file - fighting and winning with Visual Studio

There is an important trick I learned years ago that I always refer to as "The evil suo file" that I thought was more common knowledge than I guess it is. I realized this when I had to show it to my esteemed colleague Michele and she had never heard of it. It has happened to me dozens and dozens of times and dates back to VS 2003 or VS 2002 was when I first learned it, source long forgotten.

Here is the deal. If you are debugging and you are staring at the code and have something weird happening in Visual Studio. If you can convince yourself there is no way this could be happening, the code just can't/shouldn't be doing what you are seeing. In Michele's case we were stepping through the code, watching one line of code setting a property, seeing that no other code set the property through a breakpoint in the setter, and then a line of code read the property and it was a different value than last set.

One thing you should try is to close VS, delete the suo file in the solution folder, and open the solution and try it again. Like I said, dozens and dozens of times, this has made something really squirrely go away for me.

My general fighting and winning with VS is this. Convince myself that I am not just trying to blame VS for something wrong with my code. VS is a wonderful, powerful, amazing tool that makes our lives SO much easier than they used to be.

1) If VS is doing something weird, close and reopen, and try again.

2) If VS is still doing something weird, close delete suo, and reopen and try again.

3) If VS is still doing something weird, close and Clean Sources (delete suo and all obj/bin folders), reopen  and try again.

4) If VS is complaining about references to do with a project, remove it from the solution and add it back in. This happened with a customer this week where VS was insisting we were trying to add a circular reference when trying to add a ref to a particular project in the solution, and it was just lying. Removing it from the solution and adding it back in (and of course patching all the removed references from all the dependent project) fixed it.

5) If you have any add-ins, go to Tools > Add in manager and uncheck the startup box for all add ins. Close and reopen studio and see if the problem goes away. If so you may have a problematic add-in.

If those don't do it, it was probably your code in the first place.

Again, VS is an awesome dev environment. We really have it good. However, it is not perfect like most software. Don't waste hours chasing goblins in your code when it may just be a touch of gas in the VS belly.





Saturday, May 10, 2008 2:00:07 PM (GMT Standard Time, UTC+00:00)
Comments [4]  | 


Sunday, May 11, 2008 10:15:39 PM (GMT Standard Time, UTC+00:00)
There are some perfectly good reasons why you are having almost all of the problems above, and deleting the suo file is just fixing the signal of the error.
Read up on assembly referenceing resolution in visual studio or research the msbuild files and you'll see.
OddHelge
Monday, May 12, 2008 8:49:11 PM (GMT Standard Time, UTC+00:00)
Could you be more specific? If there are known issues related to these problems, a URL or more specific reference would be helpful to all.
Brian
Thursday, May 15, 2008 12:52:45 PM (GMT Standard Time, UTC+00:00)
Good tips, thanks.
Friday, May 16, 2008 5:42:42 PM (GMT Standard Time, UTC+00:00)
Quote: "However, it is not perfect like most software"

So are you saying that most software is perfect and VS is not? :)

I think you meant: "However, like most software, it is not perfect"

Just trying to have some fun with you - Thanks for the suggestions!
Vaxman2
Comments are closed.



















Sign In
Copyright © 2006-2007 Brian Noyes. All rights reserved.
designed by NUKEATION STUDIOS