I write an add-in for and with Visual Studio 2008 standard using Vista SP1.
When I use own button images with "Commands2.AddNamedCommand2" and step over this function call, the following debug output message appears:
A first chance exception of type 'System.IO.FileLoadException' occurred in mscorlib.dll The button image is correctly displayed in the menu afterwards though.
I can reproduce this in a new project too. Here is how I'm able to reproduce the problem:
- Create a new Visual Studio Add-in using the corresponding template
- Name the project "MyAddin1"
- Open project properties and set Assemblyname to "MyAddin1"
- Open the "MyAddin1 - For Testing.AddIn" link and modify the assembly path to point to "MyAddin1.dll"
- Set AssemblyCulture to "en-US" in AssemblyInfo.cs
- Create the directory "MyAddin1\bin\en-US"
How I add the image resource:
- Add new item, General -> Resource Files
- Name the file "Resources1.resx"
- Doubleclick Resources1.resx to open it
- Set its Build Action to "none"
- Add resource -> Add existing file
- Select a 24bit 16x16 bitmap image called 1000.bmp
- Select "Exclude from project"
- Open Resources1.resx in notepad and change the data name "_1000" to "1000"
How I generate the satellite dll:
- resgen Resources1.resx
- al.exe /embed:Resources1.resources /culture:en-US /out:MyAddin1.resources.dll
- copy /y MyAddin1.resources.dll bin\en-US\MyAddin1.resources.dll
Now is the file "MyAddin1.resources.dll" located in "MyAddin1\bin\en-US". I switch back to Visual Studio and change the auto-generated source code to use the image resource 1000:
Command command = commands.AddNamedCommand2(_addInInstance, "MyAddin1", "MyAddin1", "Executes the command for MyAddin1", false, 1000, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported+(int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);
I set a breakpoint at this line and hit F5 to start and debug MyAddin1. When I step over this line, it prints the following to the debug output pane:
A first chance exception of type 'System.IO.FileLoadException' occurred in mscorlib.dll However, when I continue program execution and open the Tools menu, MyAddin1 button appears with my button image resource 1000.
I did try many different approaches how satellite dll's should be created. The above is how MS recommends that. I also tried articles from mz-tools, but no matter what article I follow, I always get this exception.
Any idea what could cause this exception?