6

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.

user3220129
  • 503
  • 9
  • 24

2 Answers2

0

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.

shree.pat18
  • 21,449
  • 3
  • 43
  • 63
  • Thanks for your suggestion. I have currently referenced the interop dll through COM reference in Visual Studio which by default points to assembly path. Is this correct, or should I copy the dll to a project folder and then reference it? Please suggest. – user3220129 Apr 07 '14 at 07:14
  • I believe it's OK to reference from Visual Studio and leave it at that. I don't usually copy the DLL into the folder where my executable is deployed. – shree.pat18 Apr 07 '14 at 07:19
  • Thanks for your reply. I will follow the approach of installing MS Excel in build servers. – user3220129 Apr 07 '14 at 07:24
  • Glad to help. Please remember to mark the answer as accepted if it helped. Also, you may want to watch out for some of the pitfalls of using Excel Interop, such as those described here: http://arturomonriv.blogspot.sg/2011/11/net-interop-pitfalls.html – shree.pat18 Apr 07 '14 at 07:27
-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”.

AtmiyaDas2014
  • 300
  • 1
  • 3
  • 25