GAC and Aspose.Excel


#1

The code I wrote that used Aspose.Excel in an ASP.Net page worked fine. A console utility worked well too. Later when I created the same methods in a class for a dll file part of a larger project, I encountered a security error:

System.IO.FileLoadException: Access is denied: 'Aspose.Excel'.File name: "Aspose.Excel" at *********.**********.ETLUtility.DataFile.ExcelToDataTable() at *************.*********.Research.Search.NPRB.Upload(Byte[] fileReadBuffer, Int32 uploadFileSize, String uploadFileName, String originalFileName, String contentType) in d:\cdo\research\search\prb\nprb.cs:line 455=== Pre-bind state information ===LOG: DisplayName = Aspose.Excel, Version=3.3.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56 (Fully-specified)LOG: Appbase = file:///D:/Data/************LOG: Initial PrivatePath = binCalling assembly : ETLUtility, Version=1.0.2060.18561, Culture=neutral, PublicKeyToken=null.===LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/root/dd42c740/ea0554e/Aspose.Excel.DLL.LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/root/dd42c740/ea0554e/Aspose.Excel/Aspose.Excel.DLL.LOG: Attempting download of new URL file:///D:/Data/westlaw/bin/Aspose.Excel.DLL.


By loading the dll into GAC, the error goes away:
>gacutil /i aspose.excel.dll
100% ok!

But....

My client has a large xcopy deployment with a 'no touch' GAC policy for their production web farm.

Can I use a System.Security method or [assembly..] code in order to make the DLL load without putting it into GAC? I looked at the Aspose DLL using caspol.exe and it doesn't look like you are doing anything unusual. I also switched off CAS but it did nothing to eliminate the error above.

The DLL appears to be looking at itself and its own directory for the license file which causes the exception.

Can you explain what might be the cause of the problem, and do you have any tips for getting it to work without putting it into GAC?

Or if you have any ideas on what I can try next I'd appreciate your help!

Oh, also I should mention that you should include the manifest in your DLL only patch releases. I tried one and it mis-matched with the XML file, so I needed to run with the 3.3.3. full msi installer version.

Aaron


#2
  1. When you deploy the new fix, please rebuild it with your project.

    2. This FileLoadException is caused by security setting. Putting it to GAC is the easiest way. If you cannot deploy it in GAC, you should manually config it and assign enough rights to run it.

    3. The dll does seach for the license file but it shouldn’t cause this exception. From the exception message, Aspose.Excel.dll is not load and none of code had been run.

    4. Next time we will zip the xml file with the dll patch.

#3

Ok. I'll try those. Thanks!

The security setting error I had earlier today occured on my XP Pro machine which has Office 2k3 on it.

On my 2003 server with no Office installed, a similar test seems to be working fine. I'll try this code again tomorrow and compare security settings.

Below is some sample code I wrote to test the call from a wrapper class:

Test wrapper dll (AsposeWrapper.dll):

using System;
using System.IO;
using System.Data;
using Aspose.Excel;

namespace MyWrapper.MyAspose.MyExcel
{
public class OpenAndWriteExcel
{
public string CopyDataTable(string fromPath, string toPath)
{
Excel excel = new Excel();
excel.Open(fromPath, FileFormatType.Excel97);

//Export the file to a dataTable object
Cells excelTableCells = excel.Worksheets[0].Cells;
DataTable dt = new DataTable("TermList");
dt = excelTableCells.ExportDataTable(0, 0, 3, 3);

//Import the dataTable object
excelTableCells.ImportDataTable(dt, false, 0, 0);
excel.Save(toPath, FileFormatType.Excel97);

return "Successful";
}
}
}


Compile:
>csc /t:library /r:aspose.excel.dll AsposeWrapper.cs
Throw dll in bin directory..


Test aspx file:

<%@ Page Language="C#" %>
<%@ Import Namespace="MyWrapper.MyAspose.MyExcel" %>

Aspose Wrapper Test


Testing Aspose Wrapper