Jim Rogers

Lives in Baton Rouge, LA, with two dogs, one cat, and one lovely wife. I'm a lead developer for GCR & Associates.

Katrin and Jim

Month List

Pack URIs in Libraries

by Jim May 13, 2008 5:00 PM

Based on the MSDN documentation on pack URIs, I would expect that code in my library which references a local resource would use the "local assembly" version of the pack URI:

pack://application:,,,/ResourceImage.png

But that's not the case; code that is in the library has to use the "referenced assembly" version of the pack URI, just like code in the main application which uses the library:

pack://application:,,,/ReferencedAssembly;component/ResourceImage.png

So a relative pack URI is supposed to be relative to the code, but an absolute URI is based not on the code's location, but that of the main assembly in which it runs.

I was using a relative URI when my resources and base class were in the application, but when I moved them to the library this no longer worked. This doesn't seem right, since the image and code that referenced it were were still in the same assembly, and MSDN says the following:

By default, a relative pack URI is considered relative to the location of the markup or code that contains the reference.

Tags:

Code

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading