I am getting the following unhandled exception when I try to create an excel document using my c# application. This process works fine when I am running the c# application from visual studio 10, but when I try to run the application outside of visual studio using the .exe file this error is appearing.
System.IO.FileNotFoundException: Could not load file or assembly 'ExcelApi, Version=1.5.1.2, Culture=neutral, PublicKeyToken=9084b9221296229e' or one of its dependencies. The system cannot find the file specified.
File name: 'ExcelApi, Version=1.5.1.2, Culture=neutral, PublicKeyToken=9084b9221296229e'
1 Answer 1
Apparently your project has an assembly called ExcelApi.dll which is missing on the target machine. I assume this is a NetOffice dll, which is required in the output directory for your project to run.
Open your project directory (depending on your VS version, you can right-click the project in Solution Explorer and choose Open Folder in Windows Explorer). Go into the \bin folder, then into the folder that matches your build configuration (most likely Debug, but it might be something else depending on how your project is set up). In that directory, copy all of the .exe, .dll, and .config files to the directory you're trying to run your program from.
In particular, you will need at a minimum your executable and config file, along with ExcelApi.dll, OfficeApi.dll, VBIDEApi.dll, and NetOffice.dll. See here for details.