Saturday, October 17, 2009

Problems with CSS and themes when using ASP.NET Forms Authentication

A while back, I wrote a blog post about how turning on Forms Authentication caused problems with stylesheets and Themes.  A lot of people found this post useful but had trouble finding it.  One reader suggested I change the title to get more hits.  So, I did, and this is it. 

Monday, July 27, 2009

ReSharper for Visual Studio 2010

rs I don’t know how I missed this for so long, but JetBrains have released a preview of ReSharper for Visual Studio 2010! They say this version is neither 4.5.1 nor 5.0, but a preview build with some of the new 5.0 features enabled.

Looking at the nightly builds, it seems that the first release was 9th July, but there was no news on their blog, which I’ve been checking daily since June (when they said it’d be ready).

Anyway, now I can give Visual Studio 2010 another try.  I just couldn’t use it, not even for evaluation, without ReSharper!

Also, let’s not forget that version 4.5.1 for Visual Studio 2005 and 2008 is also now available.

Thursday, June 04, 2009

Google Squared and sexy languages!

Google Squared looks like an interesting tool. 

“Google Squared is a search tool that helps you quickly build a collection of facts from the Web for any topic you specify.

  • Facts about your topic are organized as a table of items and attributes (we call them "Squares" for fun).
  • Customize these Squares to see just the items and attributes you're interested in.
  • See the websites that served as sources for the information in your Square.
  • Save and share Squares with others.”


There’s some interesting results.  I searched for ‘programming languages’

It displays a list of languages, a picture of the language, a description, and what it was influenced by.

I was very surprised to see the Miranda language (apparently influenced by Haskell).  Try it yourself:  scroll down to Miranda.  I must take a closer look at this one!

limbo Another one that might get you excited is Limbo.  Scroll down and take a look (but be careful if you’re at work!!). Apparently influenced from Stackless Python.  I’d say more like alcohol!

Monday, May 25, 2009

Updated: Tree Trim

Tree Trim is a command line tool that trims your source code tree.  It removes debug files, source control bindings, and temporary files.

It’s integrated with Windows Explorer: when you right click a folder you’re given the option to clean the folder.

Massive thanks to Scott Hanselman for blogging about it and for providing some great and detailed feedback.

If you’re interested in doing your own Tree Trim plugin, there’s now a Wiki page to take you through the process.  If you’d like to contribute your plugin or fix any issues, then take a look at this page.

Friday, May 15, 2009

Updated: Code Formatter Plugin for Windows Live Writer

Version of the Code Formatter Plugin can be downloaded here.  This has a fix for when the plugin tried to load configuration from the wrong location on disk.

Monday, April 13, 2009

New tool: TreeTrim

hammer I've recently been working on a tool based on Jeff Atwoods Clean Sources Plus

It's called TreeTrim.  It's a tool that strips out debug files and folders in your source code tree and also zips and emails amongst other things.

One of the BIG requests for CleanSourcePlus (well, amongst the 5 people in the comments section of the tool's page!) is for the tool to make a working copy of your source before it deletes and zips.  TreeTrim does this.

It's plug-in based, so if it doesn't do something that you want, you can write your own plug-in, plonk it in the directory, and have the tool run it alongside the other plugins.

The installer and source code is available for download at

Thursday, March 12, 2009

Update to the Code Formatter Plugin

Version of the Code Formatter Plugin is now available.

New in this version:

  1. Enhanced support for Syntax Highlighter 2x
    You can now specify things such as tab size, show ruler, collapseshow toolbar, show line numbers, starting line number, and highlighting specific line numbers
  2. Configuration screens for the different providers
    You can now add and remove languages and generally configure each provider.  You can also edit the files manually – they are called SyntaxHightlighter2xConfiguration.xml and ActiProConfiguration.xml.  They are located in the Plugins folder.
  3. Preview window for Syntax Highlighter formatted code.
    This was added because the Preview tab in Windows Live Writer doesn’t include the scripts and styles used in your blog engine’s templates and hence previewing Syntax Highlighted code means it looks plain.  Click the Show Preview button to see this window.

Code Formatter Plugin home-page
Direct download link

Friday, March 06, 2009

IDisposable alerts

Types that implement IDisposable usually do so for a reason.  They probably consume resources that should be released as early as possible.

In a recent project, I came across a very neat idea.  In the destructor/finalizer/finaliser of your IDisposable type, do something to alert the consumer that you’re being collected by the Garbage Collector and hence you haven’t been disposed of correctly.

But how does this type know it’s not been disposed correctly?  Well, if you follow the IDisposable pattern to the letter (described in the excellent book Effective C# (Item 18), and about 3,000 places around t’internet), in your Dispose method, you’ll call GC.SupressFinalize(this);  meaning the Garbage Collector won’t call your finalizer.  So if you ever end up in the finalizer, the naughty user hasn’t called Dispose or hasn’t put the construction of your type in a using block.

There’s two bits to this

The constructor:

public MyResourceHungryType( )
  _stackTrace = new StackTrace( ) ;

The finalizer:
~MyResourceHungryType( )
  Debug.WriteLine( _stackTrace.ToString( ) ) ;

Then, if the finalizer is ever called, you’ll get a call stack printed up to the point where you created this type – something like:
at Namespace.MyResourceHungryType..ctor()
   at Namespace.MyType.DoSomething()
   at SomeNamespace.SomeMethod()


New version of the Code Formatter Plugin

Version 2.0 of the Code Formatter Plugin for Windows Live Writer is now available.

New in this version is the ability to use different formatting engines – in this version: ActiPro and SyntaxHighlighter 2.0

Also new is the ability to output either formatted code as text or as a bitmap.

A massive thank you to ActiPro for donating the ActiPro Syntax Editor component – the best code editor available!

If you’re reading this in an aggregator, the following code snippets may look unformatted (apart from the bitmap), but if you’re not, then it should be all nicely formatted.

Here’s some output from ActiPro as text:

public int TabWidth
      return _content.GetInt(@"TabWidth", 4);
      _content.SetInt(@"TabWidth", value);

Here it is again as a bitmap:


and here it is using SyntaxHighlighter 2.0

public int TabWidth
      return _content.GetInt(@"TabWidth", 4);
      _content.SetInt(@"TabWidth", value);

Please feel free to read more and download it.

Thursday, March 05, 2009

Online mind maps in Silverlight

I’m a big fan of mind maps.  I use MindManager, but there’s now an online Silverlight alternative from DropMind

It’s currently in beta, so there’s a few things that need addressing to make it as nice to use as MindManager (such as keyboard navigation).  Despite this, it looks feature packed compared to other online mind mapping tools I’ve tried.

There’s also a desktop version.  It has none of the above keyboard problems.  It also looks and feels very similar to MindManager:





It’s nice to see Silverlight apps like this.  I’d probably switch to it once all the glitches are resolved.  MindManager’s great, but it comes with a lot of fluff I don’t need, like Office integration and RSS features.

Wednesday, March 04, 2009

Halt, this is StyleCop. You are in violation of SA1201!

StyleCop has a law rule named SA1201. It says that you should put various parts of your code in the correct order.  For the contents of a class this goes like:

  1. Fields
  2. Constructors
  3. Finalizers (Destructors)
  4. Delegates
  5. Events
  6. Enums
  7. Interfaces
  8. Properties
  9. Indexers
  10. Methods
  11. Structs
  12. Classes

Doing all this by hand is tedious, but as with most things, ReSharper (R#) makes it easier!

R# has a couple of features that, when combined, will mean you are fully SA1201 compliant (and, quite possibly well within the 20 seconds compliance window!)  Firstly, there is a feature called Code Cleanup:


You can get R# to do various things during code clean-up.  One of them is Reorder Type Members.  R# does a decent job of moving stuff around by default, but it’s not perfect and doesn’t stop all warnings about SA1201.  Thankfully, Reorder Type Members is configurable.  The interface is straight XML in the R# Options screen.  It’d be nice to have a GUI over it, but as yet (in R# 4.1 and 4.5), there isn’t one.  Thankfully, you can’t bugger things up too much as the XML is validated against an XSD before it’s saved.

I was going through a legacy project recently and wanted a way to automatically reorder things, so I modified the R# XML configuration.  To get your environment set-up, download the new XML configuration, go to ReSharper/Options and under languages/C# there an entry named Type Members Layout.


Deselect Use Default Patterns check-box and past in the new XML and click OK.

If you want a C# class that contains most of the things that should be reorganised, download it here.  Mash it up a bit and then run StyleCop on it to ensure no SA1201 errors.

Tuesday, March 03, 2009

Hiding your privates from StyleCop

I like StyleCop but I didn’t like the fact it produced warnings on private fields and methods.  I was wrong. Not wrong in that I didn’t like warnings on privates, but wrong that I thought there was no way to tell it to stop it.

Apparently there is.  Jason Allor kindly left a comment saying that it can be configured through the StyleCop settings dialog in Visual Studio.

I took a look and initially didn’t find it.  I didn’t find it because I assumed there’d be different rules for public and private entities.  But there’s not, you can decide at the rule type level:


It’d be nice to have separate rules for public and private.  Currently, I’ve turned off all Documentation rules because I don’t like being warned that I haven’t commented private methods.  However, I’d still like it to give me all the other great warnings if I do decide to comment a particular private method.

Programs that launch (or should launch) Visual Studio

Programs such as FxCop provide links to source files that can be clicked and then edited in Visual Studio. 

FxCop recently (probably since I went 64bit, but also possibly a side-effect of running Windows 7) started failing when clicking these links.  It said:

Could not start Microsoft Visual Studio. Try specifying an alternate source code editor in Application Settings.

Maybe it just looks in \Program Files\Microsoft Visual Studio\[whatever version].  Anyway, I couldn’t see anything in the event log or any local FxCop logs, so I just changed the setting under Tools\Settings to use an explicit path to devenv.exe.

This worked, although it started a new instance of the IDE for every file.  To get around that, you need to use the /Edit argument.  Here’s what it looks like (click to make it bigger):


There’s other handy switches, some of which I knew about, like building a particular project/solution (to get the full list, run devenv.exe /?).   It now uses an existing instance of Visual Studio if one’s present, otherwise it starts one up. 

Thursday, February 26, 2009

ThoughtWork’s Mingle on X64 machines

By default, 32 bit applications installed on 64 bit machines are installed into the \Program Files (x86) directory.

Mingle, in particular, Ruby doesn’t like the brackets in this path, hence, when Mingle tries to start, it fails.  It writes the following entries to the log file in the program’s directory:

Failed to load Rails: C:/Program Files (x86)/Mingle_2_2/app/controllers/caching/keys.rb:1: Invalid char `\257’ (‘¯’) in expression C:/Program Files (x86)/Mingle_2_2/vendor/rails/activesupport/lib/active_support/dependencies.rb:505:in `load’ C:/Program Files (x86)/Mingle_2_2/config/../vendor/rails/railties/lib/initializer.rb:475:in `load_application_initializers’ C:/Program Files (x86)/Mingle_2_2/config/../vendor/rails/railties/lib/initializer.rb:474:in `each’ C:/Program Files (x86)/Mingle_2_2/config/../vendor/rails/railties/lib/initializer.rb:474:in `load_application_initializers’ C:/Program Files (x86)/Mingle_2_2/config/../vendor/rails/railties/lib/initializer.rb:145:in `process’ C:/Program Files (x86)/Mingle_2_2/config/../vendor/rails/railties/lib/initializer.rb:93:in `run’ C:/Program Files (x86)/Mingle_2_2/config/environment.rb:116 C:/Program Files (x86)/Mingle_2_2/config/environment.rb:1

The solution: change the default installation to just \Program Files.  Handy.  If you want to use Mingle.  On a 64 bit machine.

Tuesday, February 24, 2009

Problems adding an XBox 360 Media Center Extender

Skip this if you’re not using a Linksys Wireless N device, Media Center, or an XBox 360!

After my umpteenth Seagate disk packed up yesterday, I’ve just reinstalled Windows 7 X64.  I have spent the last couple of hours trying to get an XBox 360 connected to Windows Media Center.

Not too long ago I went through the exact same thing:  Start WMC, Start the XBox,  type the number on the XBox’s screen into WMC, and get nothing.  The last time I did this, it was too late in the day to discover what was wrong or how to fix it – but the next day, everything worked perfectly!

This time, I went through exactly the same ritual.  I looked at the Security event log and it said that :

Event 5032 – Audit Failure - Windows Firewall was unable to notify the user that it blocked an application from accepting incoming connections on the network.

After ensuring that I’d allowed Media Center Extenders through the home network (shortly followed by turning the damn firewall off altogether), I started getting (from the Media Center log under Applications and Services Logs in Event Viewer):

Event 538 - Media Center Extender Setup failed as the Extender was detected on the network but the UPnP search for the Extender failed (timed out after 20000ms).

This all seemed very familiar and nothing I was doing was making a difference.  It was at this point on my last attempt that I went off to do something else.  This time though, the something else’s opening hours hadn’t yet arrived, so I persevered!

In the corner of the screen (remember, this is a fresh install), was the Windows Update icon.  I checked to see what it needed to update, and along with the 294 Office 2007 security patches was an update for a Marvell - Network – Wireless-N USB Network Adapter.  I wondered if this had anything to do with my Linksys Wireless N USB, and it looks like it does.  And after restarting, everything worked great!

The information from Windows Update showed this information:

Marvell - Network - Wireless-N USB Network Adapter

Update type: Optional

DriverUpdate: Marvell Network software update released in October, 2007

More information:


The URL wasn’t much good as it was broken.  The driver information from device manager reads:

Marvell Semiconductor, Inc, version – filename MRVW24C.sys.

This replaced the Vista drivers that I downloaded and installed from the Cisco site.

In fact, I’ve just done a search for Marvell Linksys driver, and it showed this page.  This shows how to force the driver on Vista/Windows 7 if it doesn’t show up via Windows Update.

I hope some of these keywords will help others with this problem.  My heart sank when I searched for the Media Center error and didn’t get 1 single hit!  That shouldn’t happen any more!

Monday, February 23, 2009

Tool update: Visual Studio Orphaned Items


A while back I did a small simple tool to find files on disk that were once part of a Visual Studio project but are now orphaned (removed from the project but still on disk and in your source repository).  I’ve just updated it to find obsolete files from Visual Studio 2008 projects.  You can download the app or the installer, or the source (or all of them!).  The installer adds a right-click context menu action for .csproj files in Windows Explorer.

Available here.

Saturday, February 21, 2009


StyleCop is a tool that looks at your source code and recommends ways to improve readability and consistency.  For instance, it tells you to:

  1. Put things in a consistent order in the file – Constructors first, followed by public methods, followed by private methods etc.
  2. Put a blank line after a closing brace.  I thought this was a bit anal, but for some reason it makes code much more readable.  On a related note, some people swear by having no blank lines in their source.  Their reasoning: they can see more on screen without having to scroll and can see more of the method on screen at once.  To me, this was like reading a book with no paragraphs.  Also, If you’ve got methods that take up a whole screen, they’re probably doing too much and are too complex.  I was invited to try it with the reassurance that I’d eventually see the benefit.  I declined, but then realised that I had been ‘trying it’ all along - every time I read the code! 
  3. Remove unnecessary parenthesis.  Reminds of a quote:  “Parenthesis (however relevant) are unnecessary.”
  4. Add XML comments to methods, properties, and events.

There’s hundreds of suggestions, mostly good, although there are some issues – here’s mine:

  1. I generally don’t like to comment private methods, but there doesn’t seem a way to tell it to only warn me if I have public methods that are undocumented.  I hope this’ll be added to the next version.  I don’t like commenting private methods as, if I feel it needs a comment, then the code isn’t self describing and is either a) poorly named, or b) too complex, or c) doing too much.
  2. StyleCop says don’t precede field names with notation.  I follow the almost ubiquitous practice of preceding private fields with an underscore.  For no other reason than to be able to type underscore + ctrl+space and have intellisense pop-up my private fields.  

The good news is that it’s possible to turn off  warnings.  It’s also very well thought out in how these settings are managed:  If you think a certain warning is so ridiculous you never want to see it again, you can put it in the StyleCop.Settings file and put this file at the top of your source tree.  If you’ve got a project where it would make sense to turn off a warning just for that project, you can put another StyleCop.Settings file at the project level.  More here.

I’m wondering if anybody would be brave enough to integrate this in their CI process!  Breaking the build because there’s not a blank line under a brace seems a tad extreme!