Visual Studio Orphaned Project Items Finder

The name is a bit of a mouthful, but sums up what it’s all about.  It finds orphaned items in a Visual Studio project.  Inspired by Clean Source Plus, this utility is a stand-alone application and also a right-click Explorer menu item.

Recently I came across several dozen projects that had been worked on by dozens of people for several years.  Inevitably, there were files present in the source tree that were not part of the project.

This is a tool to find those files.  Please feel free to download it from CodePlex.  There is an installer file and the source code is also available. If you’d like to contribute to the project, please let me know.

To use it is very simple.  Download it and run it, or right click a Visual Studio project in Explorer and ‘Find Orphaned Items…’.


I’ve tested this project on Visual Studio 2003 and 2005 projects.  I haven’t tested this on Web Projects or Web Application Projects (in Visual Studio 2005).  I would recommend verifying what the application thinks are orhpaned items.  If it continually gets it right, you can trust it more and check it less.  If it continually gets it wrong, then please let me know!

Problems with Forms Authentication and ASP.NET Themes

It’s sometimes the strangest (and seemingly irrelevant) combinations of technology that give you the most problems. For a good few hours I’ve been wondering why my web site, which uses Forms Authentication and Themes, was not displaying any formatting or images.

It turns out that the URLs specified in the authentication section in web.config are used for ALL resources. So, in my case, the page was trying to load a .css file but ASP.NET was redirecting the request to default.aspx, which of course, is not a style-sheet and has a different MIME type. Here’s the section of my web.config file:

To fix this, I allow unauthenticated access to the resources, which was straight-forward. I added the following to the web.config file:

The tricky part in finding this was that the page’s HTML looked fine, there were no errors, and saving the resulting HTML to a file and viewing it produced the right results.

Firefox’s JavaScript Console proved incredibly helpful in finding the problem:

Once I saw this, it all fell into place!

BackgroundWorker – automating this handy class

BackgroundWorker objects are an addition to .NET 2.0 to simplify asynchronous programming and are very useful in (but not restricted to) Windows Forms.

The basic idea is:

  • Create a BackgroundWorker object
  • Set-up various events on it, like DoWork, RunWorkerCompleted, and ProgressChanged
  • Set-up various properties, like WorkerReportsProgress and WorkerSupportCancellation
  • Call RunWorkerAysnc

…then, in your form you get notified of progress and can cancel the operation at any time.

I’ve created a ReSharper Live Template that will help you create and set-up the BackgroundWorker object. You can download it here. For instructions on importing the Live Template into ReSharper, see my previous post here.

Visual Studio Build Tip

By default, Visual Studio will build all of the projects in your solution regardless of any errors.

The problem with this is that if the first project it builds contains an error, the resulting binary will not get generated. If any other projects depend on this (which is normally the case, as it was the first to be built) then they’ll fail too, and so on to the end of the project heirarchy.

Pointless; you’ll spend ages sitting around in a locked IDE unable to edit the error until the build finishes.

You might as well stop at the first error. You could of press Ctrl+Break (several times) and hope that VS will eventually stop. But, there’s a better way: get Visual Studio to stop automatically after an error.

  1. Go to Tools/Macros/Macro Explorer
  2. Expand MyMacros
  3. Double click Module1
  4. This will bring up the macro in a new window. In that window, double click the EnvironmentEvents entry.
  5. From the drop-down (currently ‘General’, select ‘Build Events’)
  6. Select ‘OnBuildProjConfigDone’ and paste this in: