0

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'
asked Oct 31, 2012 at 12:24

1 Answer 1

3

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.

Bart
20.1k8 gold badges71 silver badges80 bronze badges
answered Oct 31, 2012 at 13:00

2 Comments

Thanks for the response. I guess my only concern is that I will be distributing this c# application to users who are not very computer efficient or literate and I am concerned about making the set up process too difficult for them. With the basic Excel Interop I was just able to run the .exe file from the project -> bin -> debug folder and the application worked fine. However, I encountered issues with the Microsoft.Office.Excel.Interop which caused me to switch to NetOffice
If you want to make it easier, your best bet is probably to wrap it as a ClickOnce application (if it will be run from your network) or create an installer for it. Both of those are relatively easy things to do which will make life easier for your users, but they're outside the scope of what I can explain in a comment. I'd recommend doing looking over msdn.microsoft.com/en-us/library/wtzawcsz(v=vs.80).aspx, as well as wix.sourceforge.net for some ideas.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.