title: Why can't this jpg resource in be found within its own library?
body: <p>Doing some refactoring of some projects and I'm running into a resource issue that has me stumped.  I'm having trouble loading resources from within a library.  The same code runs fine within the main app (if I move the resource there of course.)</p>
  <p>Here's the app version that works...</p>
  <pre class="lang-none prettyprint-override"><code>MyApp.csproj
   - Resources
      - Images
         SomeFile.jpg &lt;-- Set to 'Resource' in the properties grid
  </code></pre>
  <p>I then have the following code running in the app which works fine.</p>
  <pre class="lang-cs prettyprint-override"><code>var imageSourceConverter = new ImageSourceConverter();
  var packUriString = $&quot;pack://application:,,,/Resources/Images/SomeFile.jpg&quot;;
  someImage.Source = imageSourceConverter.ConvertFromString(packUriString) as ImageSource;
  </code></pre>
  <p>I then try to move both this code and the resource to a new library 'MyLibrary', like so...</p>
  <pre class="lang-none prettyprint-override"><code>MyLibrary.csproj
   - Resources
      - Images
         SomeFile.jpg &lt;-- Set to 'Resource' in the properties grid
  </code></pre>
  <p>And try the same (again, from within 'MyLibrary')...</p>
  <pre class="lang-cs prettyprint-override"><code>var imageSourceConverter = new ImageSourceConverter();
  var packUriString = $&quot;pack://application:,,,/Resources/Images/SomeFile.jpg&quot;;
  someImage.Source = imageSourceConverter.ConvertFromString(packUriString) as ImageSource;
  </code></pre>
  <p>But I now get the following...</p>
  <pre class="lang-none prettyprint-override"><code>System.IO.IOException
    HResult=0x80131620
    Message=Cannot locate resource 'resources/images/somefile.jpg'.
    Source=PresentationFramework
    StackTrace:
     at MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access)
  </code></pre>
  <p>I remember issues with resources in the past not being compiled so I did a 'rebuild all' to see if that helped, but it didn't.  Still get the same issue.</p>
  <p>Any ideas?</p>