VS2010: Web Standards Update and the CSS Editor

I’ve been doing a bit of Web UI work recently and everything was going fairly smooth until yesterday when I tried opening one of my CSS files in Visual Studio and was promptly greeted with a dialog reading “The operation could not be completed. Unspecified error” and the editor never opened.  A little hunting for the error message and “CSS editor” revealed that the Web Standards Update for Microsoft Visual Studio 2010 SP1 was likely to be the culprit and uninstalling should resolve the issue.

I closed Visual Studio, uninstalled the update, and sure enough, when I reopened my project the CSS file opened just fine. I haven’t reinstalled the update yet. Maybe I’ll try again soon but it seems from the comments on the component’s page that this is a common issue.

More information:


Operation could destabilize the runtime

Today I was trying to run the code for a project I’ve just been assigned to.  I’d brought down the code from SVN, built the common libraries, and punched F5.  Build succeeded.  Before long the browser loaded and the beautiful new UI stared back and virtually begged me to start clicking around.  Before I could do anything though Visual Studio rudely interrupted with an unhandled exception dialog.  This one looked nasty, particularly since I’d never seen it before: System.Security.VerificationException – Operation could destabilize the runtime…

I found a Stack Overflow question about this that pointed to Json.NET as a possible culprit.  Sure enough, the source of the exception was Newtonsoft.Json.  It seems that Visual Studio Ultimate’s IntelliTrace didn’t like something Json.NET was doing and would throw that exception.  The issue is said to be resolved as of release 6 but I haven’t upgraded the assembly yet.

For the time being I’ve added a rule to exclude *Newtonsoft.* from the IntelliTrace modules list as recommended by in the Stack Overflow answer.  Since excluding the assembly I haven’t seen the problem again.

VS2010: Box Selections

When I first saw the box selection capabilities in Visual Studio 2010 I thought “that’s kind of neat but I’ll probably never use it” and promptly moved on.  I couldn’t have been more mistaken.  In fact, nearly two years later, box selection has become one of those features that I use almost daily.  What surprises me now though is how many developers I run into that still don’t know about them.

Box selections let us quickly make the same change to multiple lines simultaneously.  Creating them is easy – just hold shift+alt and use the arrow keys or hold the alt key while left drag the mouse to define a rectangle.  If you just want to insert the same text onto multiple lines you can define a zero-length box by expanding the box vertically in either direction.

Non-virtual Properties

So what makes box selections so useful?  Some of the things I find them most useful for are changing modifiers and making local variables implicitly typed.  To illustrate, let’s take a look at a few non-virtual properties that we’d like to make virtual.

Zero-Length Selection

Making these properties virtual without a box selection certainly isn’t difficult but it’s definitely tedious.  A box selection lets us make them all virtual at the same time so we can get on with the task at hand.  The thin blue line immediately following the public modifier on each property identifies the zero-length box that serves as the point where we’ll insert in the virtual modifier.

Virtual PropertiesTo insert the virtual modifier we just need to type (or paste) “virtual.”  Here you can see that each property is now virtual and the zero-length box has moved to the end of the inserted text.  What if we decide later though that these properties shouldn’t be virtual after all?

Box SelectionWe can use box selections to remove the virtual modifier from each property just as easily.  In the example to the left we see a box selection highlighting the virtual modifier on each line.  Non-virtual Properties 2To remove the text we can simply delete it.  This will leave us with a zero-length box where the virtual modifiers used to be.  We can then simply click or arrow away to clear the box selection.

Box selections can go a long way toward increasing your productivity by reducing some of the more tedious aspects of programming.  The few seconds they save here and there can really add up over the course of a day.  More importantly though, that time can be spent on the real problems we’re trying to solve.

Further Reading

How to: Select and Change Text

Changing the AnkhSVN Merge and Compare Tools

When my team reverted back to Subversion the first thing I missed was the Visual Studio integration from TFS.  CollabNet provides AnkhSVN to fill that gap by exposing most common source control operations directly through the IDE.  I’ve been using AnkhSVN successfully for a few months but one thing that always bugged me was the default compare tool.  I love WinMerge and the default merge and compare tool just didn’t, well, compare.  Thankfully the merge and compare tools thank AnkhSVN uses are configurable.

AnkhSVN adds a Subversion User Tools page to the Source Control folder in the Visual Studio options dialog.  From here we can select the tools to use for:

  • External Diff
  • External Merge
  • External Patch

Not only does AnkhSVN provide a list of popular tools including WinMerge and KDiff, it also attempts to determine if any of them are installed and marks any it can’t find with “(Not Found)”.  To change the tool just select it from the list or enter the path to your favorite utility.

Each of the tools are preconfigured to run with a fairly thorough set of arguments but if we want to customize them we can click the corresponding ellipsis button to open the Command Editor.  AnkhSVN uses the macro paradigm to inject a variety of variables into the argument list for the selected editor.  Its macros follow the traditional $(name) format so it should look familiar to anyone familiar with configuring external tools from Visual Studio’s Tools menu.

Ever since I found these settings and replaced the default tool with WinMerge I’ve been much happier.  AnkhSVN is a much more natural extension of my workflow than TortoiseSVN so being able to use WinMerge simplifies the process immensely.

VS2010: Find in Files

I really debated with myself about writing this post but after an exchange with a friend I decided to go ahead with it.  My team recently upgraded to new laptops with a fresh new image.  When one of my friends remarked that he was glad that the new image contained wingrep I asked why he didn’t just use Visual Studio’s Find in Files feature.  His reason?  He didn’t know about some of its features.  After talking about it a bit he said he’d give it another shot.  Now, several days later he’s using it almost exclusively.