make a com reference local - asp.net

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.

There are several libraries using only a DLL file, like EPPlus

Related

What is the purpose of the licences.licx file in ASP.NET? When is it edited?

I wonder what the purpose is of the licenses.licx file in a ASP.NET project. I can see in my commit history that the following lines were added in my last commit to the licenses.licx file:
Telerik.Web.UI.RadGrid, Telerik.Web.UI, Version=2019.1.115.45, Culture=neutral, PublicKeyToken=...
Telerik.Web.UI.RadAsyncUpload, Telerik.Web.UI, Version=2019.1.115.45, Culture=neutral, PublicKeyToken=...
Another developer asked me what difference those two added lines make to the project.
So what is the licences.licx file for and why were those two lines added automatically? I have read about it by Googling a bit but I haven't really grasped yet what the purpose of it is.
Thanks!
From the EmptyLicensesLicx project readme:
When you are developing .NET applications that use third-party controls such as the ones that you can buy from Telerik or DevExpress for example, a mysterious file called licenses.licx appears inside the Properties folder of your C# project (Or My Project folder if you're using VB .NET).
This means that the third-party control uses the licensing model provided by the .NET Framework for licensing components and controls.
This file is a transitional file generated (and modified) by Visual Studio that participates in license checking. In design mode, Visual Studio uses this file to make a note of every licensed control you use in your design. When you then build your application, Visual Studio reads this licenses.licx file and for every control mentioned there, loads the relevant assembly and runs the license code in that assembly to see if the assembly is properly licensed (that is, that the product to which it belongs has been properly installed on that machine). If everything checks out, Visual Studio embeds the license key into the executable. If it doesn't, you'll get weird error messages about the control not being licensed (my favorite is "Could not transform licenses file 'licenses.licx' into a binary resource.").
The licenses.licx is a file automatically added to your project (if you cannot see it there, click Show All Files). Visual Studio uses a program called lc.exe to compile the licenses into embedded resources in your application, and when things go wrong with the license compiling process, you might see error messages referencing this executable.
Here's an example of a line in a licenses.licx file:
DevExpress.XtraCharts.ChartControl, DevExpress.XtraCharts.v15.2.UI, Version=15.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
DevExpress.XtraMap.MapControl, DevExpress.XtraMap.v15.2, Version=15.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
Infragistics.Win.Misc.UltraButton, Infragistics2.Win.Misc.v8.1, Version=8.1.20081.1000, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb
Infragistics.Win.Misc.UltraGroupBox, Infragistics2.Win.Misc.v8.1, Version=8.1.20081.1000, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb
Each line contains a reference to a type that is contained in an assembly, in a comma delimited list format. The first value is the full name of the class, the second is the assembly that contains the class, and the other values are part of the assembly's identity.

Visual Studio 2013 can't find present DLLs

SCENARIO
I undo all my pending changes, and get latest version from TFS. I attempt to build my solution and I get errors to do with two assemblies, these are:
System.Web.Helpers
System.Web.WebPages
A different member of my team does the same as me and for her it all builds fine and the assemblies are found with zero issues.
Our web.config is the same since we both check that out of TFS.
WHAT I HAVE DONE
I asked her for the path to where the two troublesome DLLs sit on her machine, and checked the same path on my machine, they exist. I have those DLLs in the same folder and they are the same version as hers!
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\
I also compared our projname.csproj.user file to check and see if she had anything different in hers after I read this topic. But that too was the same as mine!
I then proceeded to remove the dlls, then adding them manually from the path above, and now all my errors are gone, but I then get told that my web.config has changed and needs to be checked in, and I know what has changed:
<Reference Include="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.Helpers.dll</HintPath>
<Private>False</Private>
</Reference>
The above used to be a on line, without the HintPath stuff.
I don't want this to be checked in, and it is really tiring to have to remove this stuff each time I want to check-in my code into TFS.
PROBLEM
System.Web.Webpages and System.Web.Helpers are not being loaded on my machine, but are on my other team member's machine.
possible reason is dll was registered on your colleagues machine. So it didn't have any HINTPATH. As per MSDN "Assemblies registered in the GAC won't have a HintPath entry for those references". Make sure this referenced assembly is registered on the GAC on all computers that you are trying to build the project on.
Register your dll and then try again.

Configuring asp.net web site to work with any excel version

I am using Visual Studio 2013 (asp.net, VB)
I have a created a website that creates and saves an excel document as part of a process started from a button click.
It works fine on my PC as I have excel 2013 installed and I added a reference to the office 15 object library. When I try to run it from the server I get the following error.
Could not load file or assembly 'office, Version=15.0.0.0,
Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its
dependencies. The system cannot find the file specified.
This is because the server has excel 2007 installed I am guessing. The main user of the site will be using excel 2010 for the moment. Is there any clean way of making sure my site will work regardless of the version of excel the user has?

how does vb.net handle multiple versions of the same dll

I am working on a website written 5 years ago in asp.net 2.0 and vb.net 2005 and visual studio 2005
The website uses a data access layer written using subsonic. The DAL is a class library which imports the subsonic dll. It also needs to import the mysql.data dll to connect to an underlying mysql database. Subsonic needs a specific version of the mysql.data connector (5.2.2) and so this is the version the class library imports.
The website also uses a custom membership provider for mysql. This is another class library which mysql.data dll version 6.5.4
The website uses both the DAL and the custom membership provider and so imports the dlls for both of these class files. I'm confused how it can handle the 2 different versions of the mysql data connector used by these class libraries
The web.config file has this line
<add assembly="MySql.Data, Version=6.5.4.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/></assemblies>
If i delete this line and then rebuild the website the line appears again.
The website also has a copy of the mysql.data 5.2.2 dll in the bin directory. If i delete this file and then rebuild the website the file appears again. In other words the name of the dll appears in the bin directory in the explorer window of visual studio and the physical file appears in the bin directory of the website.
I would really like to know what is going on here and how vb.net can use 2 versions of the same dll. Everything seems to be working ok but the components in this website are so old that they are unsupported. I really don't want to break anything and then not be able to fix it.
Thanks a lot

generating an asp.net web application dll requirement list

I'm trying to set up a web app (32bit on ii7/win7, 32bit setting is enabled, everything is compiled to x86, using vs2008), but there's clearly some dll module loading issue happening. I've been watching procmon and fusion logs but I'm not seeing the name of the missing dll.
I'm a complete newbie to asp.net (but fairly heavy experience on other platforms).
I know I can call depends.exe on a binary to see what the dependancies are, but how do I do it for asp.net? specifically, is it possible to get a list of the dlls that iis7 loads for my application?
update: I manually blew away all of the binaries for my application and rebuilt (clean didnt seem to do the trick, I guess). it's now sort of working. or at least it's getting further and more detailed.
An asp.net web project dll shouldn't depend on anything that is not part of the default .net run-time or explicitly referenced in the project. I would start by reviewing the references. Noramlly an asp.net web project has a bin folder that contains the compiled website/webapplication and any dll's that it depends on (aside from the .net run-time). This is usually done by the programming tool used to create the project.
If you still don't find the culprit, you could try using Filemon (http://technet.microsoft.com/en-gb/sysinternals/bb896642.aspx) and use it to watch IIS to see what files it is looking for and isn't finding.
An additional option is to examine the web.config file that should have been included with the web site/application. Its an XML file and usually has an Assemblies section that lists assemblies that should be loaded. For example you might see:
<assemblies>
<add assembly="MySql.Data, Version=6.2.3.0, Culture=neutral,
PublicKeyToken=C5687FC88969C44D"/>
</assemblies>
This means that the code wants to use the MySQL.Data.dll, and specifically version 6.2.3.0 of that DLL. It is possible to have different versions of .Net dll files installed at the same time. So you might have the desired DLL, but not the correct version as specified in the Web.Config file.

Resources