WPF Beta 2 Bug: Image.Source cannot handle mapped drive path

I’m basically going to explode if I don’t get this out soon; I’ve been sitting on this since the weekend. I’d prefer to enter this in the MSDN product feedback center and then link to it from my blog, but, alas, the Beta 2 version is not entered in the Version field of the bug report. I’ve contacted the team through their blog, so while I wait for them to enter it, I’ll blog it here

I expected to find some rough edges in WPF, but nothing quite so rough as this.

Take the following XAML:

<Window x:Class=MusicViewer.Window2

    xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation

    xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml

    Title=MusicViewer Height=300 Width=300

    >

    <Grid>

       <Image Source=E:\Music\Anthrax\folder.jpg />

    </Grid>

</Window>

The analog to this in Windows Forms would be a Form, 300 x 300, with Text set to MusicViewer containing a TableLayoutPanel, itself containing a PictureBox.

The one thing I have to tell you that you cannot get from the code is that E: is a mapped network drive.

Run this code and you get an uncaught exception of type YourXamlISRetardedException, which is essentially meaningless, because there are so many nested exceptions and you have to dig through to get to the real one. The real exception is an ArgumentException stating in its message that only the file URI is supported.

In fact, it’s a little more clear what’s going on if you expand the XAML above into the following:

<Window x:Class=MusicViewer.Window2

    xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation

    xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml

    Title=MusicViewer Height=300 Width=300

    >

    <Grid>

       <Image >

          <Image.Source>

             <BitmapImage>

                <BitmapImage.UriSource>E:\Music\Anthrax\folder.jpg</BitmapImage.UriSource>

             </BitmapImage>

          </Image.Source>

       </Image>

    </Grid>

</Window>

This is probably a more accurate representation to explain the problem. The UriSource property will create a Uri for me with the data provided. Note how succinct XAML can be with the first example. Very sexy.

Anyway, as I pointed out, E: is a mapped network drive. You can also write out the file uri for that jpg as a UNC path; something like \\server\share\music\anthrax\folder.jpg. Pass this format to the UriSource and everything works as expected; I can see the image.

Of course, I can’t discount that it might be me. I’ve tried against two machines with mapped drives and they both fail at the same place. Still, I’m confident it’s not me. I find it very hard to believe, and discouraging if it’s true, that this wasn’t included in a test plan somewhere before a Beta 2 release.

,