title: How to: Use images which are part of a dll
body: <p><strong>How to: Use images which are part of a dll</strong></p>
  
  <p>I created a dll which has a public method that uses images. These images are embedded. Now when I try using the assembly in my new project, everythings works fine except the images.</p>
  
  <p>I tried to run the application without using an assembly (just a normal WPF application) and it worked. So it seems, that the application does not find the embedded images from the dll.</p>
  
  <p><strong>The way I create the images used in my dll:</strong></p>
  
  <pre><code>public void CreateBitmapImage(string uri)
      {
          BitmapImage bitmapImage = new BitmapImage();
          bitmapImage.BeginInit();
          bitmapImage.UriSource = new Uri(uri, UriKind.Absolute);
          bitmapImage.EndInit();
          image_msgIcon.Source = bitmapImage;
      }
  
      public void SetMsgImage(string msgImage)
      {
          if (msgImage == Error)
          {
              CreateBitmapImage("pack://application:,,,/CL.New;component/Images/CustomMessageBox/cross-circle.png");
          }
          else if (msgImage == Exclamation)
          {
              CreateBitmapImage("pack://application:,,,/CL.New;component/Images/CustomMessageBox/exclamation.png");
          }
          else
          {
          }
      }
  </code></pre>
  
  <p><strong>Now I get this error message:</strong></p>
  
  <pre><code>Die Ressource "images/custommessagebox/cross-circle.png" kann nicht gefunden werden.
  The resource "images/custommessagebox/cross-circle.png" cannot be found.
  </code></pre>
  
  <p><strong>I tried it this way:</strong></p>
  
  <pre><code>CreateBitmapImage("/CL.New;component/Images/CustomMessageBox/cross-circle.png");
  </code></pre>
  
  <p>...</p>
  
  <pre><code>bitmapImage.UriSource = new Uri(uri, UriKind.Relative);
  </code></pre>
  
  <p>... this seems to work, but the image is not displayed (no error messages).</p>