"Cannot locate resource" again
I have an application which loads dlls with user controls dynamically. Inside one of the dlls I have a control which shows a button, which, when hit, pops up a new window. Everything would be great but the window does not appear... all I get is the "Cannot locate resource XXX.xaml" message with the name of the xaml which defines the window to pop up.
The window to pop up is created in a command which is binded to the button:
private void onCmdSetIndexValidator(object _param) {
IIndex param = (IIndex)_param;
new IndexValidatorsEditor(param).Show();
}
Any ideas?开发者_如何学编程
Resources in the Window need to be scoped for the assembly where they live. If you access an asset in your Window (Image, Page, etc), you need to specify the assembly it comes from (even if it comes from its own assembly). If you do not specify the assembly, WPF will assume the resource comes from the executing assembly (your client app).
Define the assembly via pack URI's. Example: /nameOfAssembly;component/folder/background.png
It also may help to look at the inner exception value of the original exception. Sometimes this provides clues as to what resource its having trouble locating.
http://msdn.microsoft.com/en-us/library/aa970069.aspx
The solution was simple... the code which loaded my dll was wrong - it used Assembly.LoadFile instead of Assembly.LoadFrom
精彩评论