problem loading resource from class library

Posted by mishal153 on Stack Overflow See other posts from Stack Overflow or by mishal153
Published on 2010-03-09T11:09:04Z Indexed on 2010/03/09 11:21 UTC
Read the original article Hit count: 187

Filed under:
|

I have a class library (mylibrary) which has a resource called "close.png". I used redGate reflector to confirm that the resource is actually present in the dll. Now i use mylibrary.dll in a project where i attempt to extract this "close.png" resource like this :

BitmapImage crossImage = new BitmapImage();
crossImage.BeginInit();
crossImage.UriSource = new Uri(@"/mylibrary;component/Resources/close.png", UriKind.RelativeOrAbsolute);
crossImage.EndInit();

This BitmapImage crossImage is then used like :

Button closeButton = new Button()
{
Content = new System.Windows.Controls.Image()
{
Source = crossImage
},
MaxWidth = 20,
MaxHeight = 20
};

On doing this i get no exceptions being thrown but the button shows no image. Also, i do see some exception info if i investigate the button's 'content' in the debugger.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about c#