I recently had the opportunity to chat with Scott Hanselman about our experiences with Synology DiskStation products and Windows Home Server. Looks like the podcast is up now so go check that out if you haven’t already.

If you’re coming in here after having listened to the podcast, here are some links to related blog entries you may be interested in:

Also, if you’re a regular Hanselminutes listener, your trivia for the day (which we touch on in the podcast): The original definition of Hanselminutes.

Finally, thanks again to Scott for having me on the show. A good time was had by all.

net, aspnet comments edit

I could also have called this “wildcard .NET mapping in IIS Express from web.config.”

I’m sure that, like, everyone out there but me has figured this out by now, but… well, I’ll blog it anyway.

Problem: Your ASP.NET web site has aVirtualPathProviderthat serves static files (e.g., .jpg, .css, etc.). It works great in the Visual Studio development web server but switching to IIS Express, it suddenly doesn’t work.

My team has just such a provider that serves static files out of embedded resources. We switched from Cassini over to IIS Express and couldn’t for the life of us figure out why it suddenly stopped working. I mean, it’s “integrated pipeline,” right? WTF?

OK, so my first “duh!” moment was when I realized that it’s integrated pipeline, not “.NET is responsible for handling each request.” That is, you have a managed request pipeline but the actual handler that serves the content may or may not be managed. It’s one of those things you know, then forget you know, then remember again when you hit a snag.

At that point I went looking in config to see what the handler was for static files and I saw this in the system.webServer/handlers section of applicationhost.config:

<add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />

This is where I made my mistake. I know what the line there says, but in my mind, I read it as “Use the StaticFileHandler for any files not previously mentioned.” So I’m thinking System.Web.StaticFileHandler, right? It’s integrated, so that’s your built-in wildcard mapping… right?

That’s not what it says.

It says, “When all else fails, use the unmanaged default mechanism to serve up the static content.” Which, further, means “skip all VirtualPathProviders and go right to disk.”

My teammate, Sagar, figured that one out and we were both slapping our foreheads. Of course. Again, integrated pipeline, not “.NET handles all requests.”

The fix is to add the .NET static file handler back into your pipeline. You can do this in your web.config in system.webServer/handlers:

<add name="AspNetStaticFileHandler" path="*" verb="*" type="System.Web.StaticFileHandler" />

We did that, and suddenly things were working again. Bam! Done.

Note that doing this has some performance and caching implications. The unmanaged, standard IIS static file handler is pretty well optimized for performance; more so than the managed static file handler. Also, the managed static file handler doesn’t write caching-related information (e.g., ETag or Expires headers) for virtual files that are not served up from disk. Something to consider.

media, music comments edit

While I’m on a recommendation kick, I figured I’d throw out five of my favorites that most people out there are probably not listening to right now, and may not have even heard of. Try something new!

In no particular order…

Album Description
Pop Will Eat Itself - Cure For Sanity Pop Will Eat Itself - Cure For Sanity -  You may recognize the name Clint Mansell from his film score work, most recently for the movie Black Swan. Mansell was originally the lead singer for PWEI. I like most of PWEI’s stuff, but this one is my favorite.

Slightly interesting personal note: it’s also one of the only two albums (along with Pretty Hate Machine) my mom ever confiscated from me when I was a kid because she didn’t like the lyrics or, I assume, the electronic/percussive nature of the music. Sorry, Mom. I think I had another copy like a week after that. It’s been one of my favorites since I originally heard it carpooling with my friend Molly to school. Still is.
2nu - Ponderous 2nu - Ponderous - I’m not even sure how to classify this. It’s more… “ambient spoken word” than straight music. If you recognize anything at all from this album, it’ll be the short-radio-run title song, “This is Ponderous.”

“I had this dream the other night. I went to work one day and nobody remembered who I was. So I decided to take the day off.”
Afghan Whigs - Gentlemen Afghan Whigs - Gentlemen - Great alternative album and a fantastic live show. This is actually the first concert I ever went to, with my buddy Mike. Super intimate venue that isn’t there anymore where I also saw George Clinton and Parliament Funkadelic (which was also a hell of a show)… but I digress. This is an awesome driving-around-town album. Go get it.
Republica - Republica Republica - Republica - You probably heard this one (maybe even had it) and forgot about it entirely. Electronic rock you want to play with the volume turned up and the windows rolled down.
Utah Saints - Utah Saints Utah Saints - Utah Saints - Great house music, period. If you’re into that sort of thing and you don’t have this one, it’s a must-have.

media, music comments edit

When I’m working (coding) I generally like some sort of music that either doesn’t have any words or is otherwise reasonably peaceful so I’m not, like, compelled to sing along or something. I also like music that sort of flows, so stuff that’s very dissonant or has an oddly syncopated rhythm, stuff that has a lot of high-pitched sirens, and so forth… that’s not so much my thing.

The list of what I listen to changes quite a bit - I have a lot of music

  • but right now, my top go-to albums for while I’m drumming out some code are (in no particular order)…
Album Description
Mirror's Edge Soundtrack Mirror’s Edge Soundtrack (MP3) - I really liked the game and the soundtrack was equally awesome. Only available in MP3 format, but that’s fine.
Tron: Legacy Reconfigured Tron: Legacy Reconfigured (CD/MP3) - The original version of the soundtrack was good, but the remixes take it up a Whole. Other. Level.
Peter Gabriel - Secret World Live Peter Gabriel - Secret World Live (CD) - This one isn’t electronic and it appears to be out of print, or at least, not directly available from Amazon (which is roughly the same thing, right?) but I find myself turning to this one a lot for some calm getting-down-to-work music.
Imogen Heap - Speak For Yourself Imogen Heap - Speak For Yourself (CD/MP3) - I actually discovered this one through Pandora and am now hooked on Imogen Heap. This is my favorite so far, particularly the song “Hide and Seek.”
Massive Attack - Mezzanine Massive Attack - Mezzanine (CD) - You’re familiar with this one if you watch House. The theme song is “Teardrop” from this album. All the songs are kind of different here (they don’t all sound like the same style) so it’s there’s a little something for everyone.
Hybrid - Wider Angle Hybrid - Wider Angle (MP3) - I like the recorded half of this much more than the live half, but the recorded half just flows. I particularly like “If I Survive,” which I originally heard on the PS2 game Kinetica.
Fluke - Risotto Fluke - Risotto (CD/MP3) - This has been a long-time favorite of mine. Originally I got hooked on this from the Sliver soundtrack (which is also pretty good).
Conjure One Conjure One - Conjure One (CD/MP3) - I have a friend who’s brother engineers these guys (that’s how I heard about them to begin with). Very cool music, sort of Enigma-ish.
Blue Man Group - Audio Blue Man Group - Audio (CD/MP3/DVD) - Sort of entrancing / hypnotic, which is cool for PVC pipe. The live show is amazing - be sure to go if you get the chance. The DVD to this has a really nice 5.1 surround mix of the music, which isn’t too helpful for an iPod or whatever, but is awesome on your home theater.
Sarah Brightman - Harem Sarah Brightman - Harem (CD/MP3) - There is just something about Sarah Brightman that I love. This is one of my favorites and the one I listen to most. There are a couple tracks on here that are a little “meh” but the really good ones outweigh the ones you have to skip.

I realized after putting this together that I could make this like a “top 25” list but then… nah. Plus, I switch it up a lot, so these are what I’m listening to now, but I may get into an Anna Phoebe mood or something for a week, which would mean this list would change. (I actually started with a top five and decided that wasn’t long enough, so I upped it to ten.)

Got any awesome recommendations? Leave ‘em in the comments!

net, vs comments edit

If you’ve enabled FxCop to run on your projects in Visual Studio, chances are you’ve seen the dreaded CA0060 warning:

MSBUILD : warning : CA0060 : The indirectly-referenced assembly ‘SomeAssembly, Version=1.2.3.4, Culture=neutral, PublicKeyToken=abcdef1234567890’ could not be found. This assembly is not required for analysis, however, analysis results could be incomplete. This assembly was referenced by: C:\Path\To\Some\Dependency.dll.

The MSDN docs on this warning say that you should just add a reference to the indirectly referenced assembly so FxCop can find it. The problem is, if you already have a reference to a later version of the indirect dependency, you can’t really reference both versions.

I found a forum post that explains that you can change the behavior of FxCop to allow resolution of dependency assemblies to look at the strong name info but ignore the version. You do that by adding the following to FxCopCmd.exe.config in the C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop folder:

<add key="AssemblyReferenceResolveMode" value="StrongNameIgnoringVersion" />

Of course, if you do that, it affects every single solution on your machine. Plus, you have to tell every developer on your team to make the same change, and… ugh. No.

A little Reflectoring shows that you can actually specify a lot more on the command line than running FxCopCmd /? says you can. Here are the ones I found that don’t show up:

  • assemblycomparemode
  • dump
  • failonassert
  • outputculture
  • targetframeworkversion
  • trace
  • tracefile

That assemblycomparemode one is what ties to the AssemblyResolveReferenceMode value from FxCopCmd.exe.config. In fact, you can pass this value in on the command line if you were running FxCopCmd.exe manually:

FxCopCmd.exe /assemblycomparemode:StrongNameIgnoringVersion [and the rest of your parameters]

Except, you’re running from inside Visual Studio, so you don’t have access to the command line… or do you?

Poking through the C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\CodeAnalysis\Microsoft.CodeAnalysis.Targets file that gets installed with Visual Studio (and is what runs FxCop), it turns out that if you provide a property called $(CodeAnalysisAdditionalOptions) with the list of additional command line options you want for FxCop, they’ll be passed in. You just have to do a little manual .csproj hacking to add the property.

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <!-- This is the first PropertyGroup in your project. -->
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <!-- ...and all the other stuff, then before the group end: -->
    <CodeAnalysisAdditionalOptions>/assemblycomparemode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions>
  </PropertyGroup>
  <!-- ...and then the rest of your project file. -->
</Project>

Now when FxCop runs, that command line parameter list will be passed in along with everything else and the CA0060 warning will go away. Plus, the setting is transported along with the individual project, so it doesn’t affect your installed config files and you don’t have to get any developers to do anything to their machines. Done!