XamlParseException when trying to access Image from Resource directory
Im using the following code to define a Ima开发者_JAVA百科geBrush in a Window or UserControl:
<ImageBrush x:Key="WindowBackground" Stretch="None" ImageSource="pack://application:,,,/Resources/bg1.tif"/>
This works great, if I use it in my normal application.
But for my testing project when I'm trying to instantiate this, I always get a XamlParseException for this line.
Any hints how to avoid that?
[TestMethod]
public void TestMethod1()
{
MainWindow window = new MainWindow();
}
I suspect that the /Resources/bg1.tif
file is copied into the directory into which your application builds and runs (eg /bin/Debug
), but not into the directory your test project builds into. You will probably need to add a post build step to copy this directory across to your test project build output dir.
精彩评论