Cannot find embedded resource in referenced assembly
I have referenced another project containing a WPF form I want to use. This form happens to have a little icon at the top left of it.
In my own VSTO project, I have a button that should call the form.
At runtime, clicking the button gives me an error saying that it cannot get the resource '$this.Icon', which is an embedded resource of the WPF form I am referencing.
I did a little test, created another Outlook plugin that calls the same form at startup. The form loads fine without errors.
Any ideas on what could be causing this; going through the code for hours yields nothing :(
EDIT : sorry, it's a winform, not the n开发者_Go百科ewer WPF
Two things to check:
Make sure the Build Action property on the icon is set to Embedded Resource.
Are you using the fully qualified name of the resource? This bit of code will dump out the names of your assembly resources:
Assembly _assembly; _assembly = Assembly.GetExecutingAssembly(); string[] names = _assembly.GetManifestResourceNames(); foreach (string name in names) System.Console.WriteLine(name);
On a project I found after running this the console showed me a few resource namespaces, but no embedded objects! Even had Image1.bmp clearly in my Solution Explorer, and in my Project properties, Resources tab, it never showed up. The trick in getting this to work is to make certain that Image1.bmp was set to Embedded Resource in the Properties window.
精彩评论