问题
I'm using Microsoft.Office.Interop.Excel reference in the windows service application to create excel reports. The application builds fine in DEV machine but in the build machine it fails saying "The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)".
It's working in DEV machine because, MS Excel 2010 is already installed. But in build server, MS Excel is not installed.
My question is whether, installing MS Excel in build server is mandatory for the build to succeed or can i copy the Microsoft.Office.Interop.Excel.dll in my project folders, reference it and check-in for the build. Currently, the dll reference added in the application points to assembly(GAC).
Another thing go to know is that, these interop dll's are not re-distributable as they are part of MS_Office product.
Please suggest me the right approach in this regard.
回答1:
You need to have MS Excel installed on the build server also. Interop DLL cannot function without Excel itself being present.
For more details on Office development, you can refer the official documentation on MSDN.
回答2:
As described in http://social.msdn.microsoft.com/Forums/vstudio/en-US/c9e83756-4ae2-4ed4-b154-1537f3bb3a22/cant-find-microsoftofficeinteropexceldll?forum=netfxsetup
On the Project menu, click "Add Reference."
On the COM tab, click Microsoft Excel Object Library, and then click Select. In Visual Studio 2012, locate Microsoft Excel 14.0 (or other version) Object Library on the COM tab.
Click OK in the Add References dialog box to accept your selections. If you are prompted to generate wrappers for the libraries that you selected, click “Yes”.
来源:https://stackoverflow.com/questions/22905601/microsoft-office-interop-excel-reference-in-build-server