This project has moved and is read-only. For the latest updates, please go here.

DeploymentCatalog and relativeUri

Aug 4, 2010 at 9:54 PM
Edited Aug 4, 2010 at 9:58 PM
Hi there,

I'm having a weird problem using MEF in a silverlight application that downloads modules on demand.

When I debug my application OOB -Out of browser- something like:


just works... However, when I debug my application In the browser, I have an exception stating the resource was not found... Then if I change the code above to:


in order to make it work... Wondering why this difference in the relative path...

Thanks in advance,


PS- I got this same behavior with the "MEFDemo_extensible" demo Glenn Block made available on his Mix Samples.

Aug 5, 2010 at 1:20 PM

Pardon me, but isn't that obvious? The hosting context is different, 'tis it not?

I'm actually just guessing here, but it's probably something like this:

The debugging experience is different wheter you go out of browser or through the browser. When you resolves a relative URI it matters what the "current working directory" is, wheter on the web or on the desktop.


Given http://localhost/mysilverlightapp/index.htm GetResource("../helloWorld") would fetch http://localhost/helloWorld while GetResource("helloWorld") would fetch http://localhost/mysilverlightapp/helloWorld this is of course not the same thing.

Also given a host name the parent directory is the same as the host, that would probably be why it works. i.e. http://localhost/../index.html is the same as http://localhost/index.htm while c:\localhost\..\index becomes just c:\index the latter case shows how this could cause a problem if the URI was treated as a UNC path.

I think you'll get a better answer for this if you turn to the Silverlight community, the resolution of a resouce has very little to do with MEF, MEF just uses what ever mechanism exposed by Silverlight. Then again, I could be dead wrong, I don't think I am, but I could be...

Aug 5, 2010 at 3:15 PM

You are right, this is a SL poblem, not a MEF issue... Thanks and sorry for the OT.


Aug 5, 2010 at 3:43 PM

I resolved the issue, leaving my experience here just in case someone else finds this useful -since SL+MEF is a pretty common combination.

Not sure why -posting on SL now- but when debugging OOB the


was pointing to somethig like this:


Instead of:



Hence it was not resolving the relative paths properly.

When I checked the properties on the web app (right click in the project > properties > Silverlight Applications) these was the order of the SL apps there:





So, removing them and adding them back in this order:




Fixed the issue and now the relative Uri  for the xaps I need to download with the DeploymentCatalog is being resolved taking the MainApp.xap as the referece -as it should be.