How do I get a resource from a referenced assembly?

Suppose I have the following projects for a silverlight application: MyApp: link to MyLib MyLib: link to MyImage MyImage

The following code will give me an error (cannot find the object):

Application.GetResourceStream(new Uri("MyImage;component/myxml.xml", UriKind.Relative))

      

I need to add a reference to MyImage in MyApp, I can avoid the error, but MyLib already has a reference to MyImage. How can I change the code to load a resource without adding a duplicate link in MyApp?

+2


source to share


1 answer


The code you posted looks correct and should work.

Something to investigate. Go to the xap you created and open it as a zip file (for example, rename it with a .zip extension). This will show the files that are in xap. Two things to check:



Is MyImage.dll split in xap?

Open AppManifest.xaml. Is MyImage.dll listed as AssemblyPart? Does the x: Name attribute have "MyImage"?

0


source







All Articles