I have a asp.net website with c# code behind and using visual studio 2010.
I added a reference to a com object “Microsoft Excel 14.0 Object Library” to manage excel files in my website. I works well in debug, on my computer where I have excel installed, but when I publish the website and deploy it on my server, it crashes because it does not find the reference (excel is not installed there). It crashes at the reference in the web.config file
<assemblies>
<add assembly="office, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/>
<add assembly="Microsoft.Vbe.Interop, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/>
</assemblies>
Is there a way to make that reference local, like a dll, so that the website is able to use it even if excel is not installed?
There’s a notion of PIA assemblies for Microsoft Office libraries. Basic idea is the following: to build solution you need to reference only PIA assemblies, that reference real office assemblies themselves. They may be distributed with the solution and be built correctly on different PCs even without office installed. I don’t know though would it run (probably would, but any excel-related function will make it crash).
But you can’t use office applications on PCs without office. It just doesn’t deploy along. So one solution would be to check if office is installed and dynamically load the necessary assembly. Ideally, excel module should be isolated from the rest of the application.