views:

318

answers:

1

Hello, I have a question about pack notation.

I'm trying to access a png image file within a XAML page from another resource assembly.

Let's say the Resource Assembly (which is outside of the local assembly that my xaml file is in), is ResourceAssembly.Common.Resources and that my image is in ResourceAssembly.Common.Resources/Images/image.png.

My pack notation looks as follows:

<Image Source="pack://application:,,,/ResourceAssembly.Common.Resources;component/Images/image.png" />

Now, I've checked this and checked it again, checked MSDN libraries, checked blogs and everything, and as far as I know, that is correct. I'm not sure why my image isn't displaying or what the problem is.

The error I'm getting is: "Error 633 Could not load file or assembly 'ResourceAssembly.Common.Resources, Culture=neutral' or one of its dependencies. The system cannot find the file specified."

I imagine I'm missing some simple keyword or some simple syntax error, or something along those lines as that always my problem, but any assistance would be invaluable.

Thanks! Anuj

+3  A: 

I had a similar problem when I started using pack notation, but I can't remember now what the specific problem was. Your pack notation looks identical to what I'm, so I would verify each part and make sure it's correct:

  1. Does the AssemblyInfo.cs for your resource assembly contain exactly: [assembly: AssemblyTitle("ResourceAssembly.Common.Resources")]? (Just making sure that ResourceAssembly.Common.Resources is the actual assembly name and not the project name or a namespace.)

  2. Does the client project have a reference to ResourceAssembly.Common.Resources assembly or project?

  3. Is there any chance a copy of ResourceAssembly.Common.Resources is installed in the GAC? (If it exists locally and in the GAC, it could cause a short name conflict.)

  4. Is the "Images" folder a direct child of the ResourceAssembly.Common.Resources project? (Sounds like it is, but just making sure.)

  5. Is the Build Action property for image.png set to Resource? (It should be by default, but you never know.)

  6. Does ResourceAssembly.Common.Resources reference any assemblies that are not included in your client project? (Pack URIs in XAML are not resolved at compile time IIRC, which means transitive dependencies will not be brought into the project.)

If it's not one of those things then it's beyond me. :)

AndyM
Thanks AndyM, your checklist was very helpful despite not being the solution to my problem.Much to my discontent I concede that upon closer inspection I discovered a very minor typo... and uh, yeah...Thanks for your help regardless though, it's working now. :)
AnujSuper9
Glad you got it working; I know the aggravation of getting them right.
AndyM