2
votes

I'm using the EPPlus library in a Visual Studio 2012 SharePoint 2010 project and get the following 'file not found' exception from an Application Page when I add "ExcelPackage pck = new ExcelPackage();" as the starting point of creating an excel file:

  • Could not load file or assembly 'EPPlus, Version=3.1.3.0, Culture=neutral, PublicKeyToken=ea159fdaa78159a1' or one of its dependencies. The system cannot find the file specified.

The library registers without a problem and the project builds and runs until the function containing the EPPLus code is called.

The same code works fine on the same machine in a standard asp.net web application.

Any suggestions appreciated, thanks.

2
How are you using the library? Is it inline code in an ASPX page? is it codebehind in a DLL?x0n
codebehind - called when a button is clicked on the web page.Niall
protected void lnkExportToExcel_Click(object sender, EventArgs e) { ... DumpExcel(dtResultsED} } private void DumpExcel(DataTable tblED) { using (ExcelPackage pck = new ExcelPackage()) { ... } }Niall

2 Answers

3
votes

You need to deploy the Assembly in the GAC.

You can add it using something like GacUtil or include the assembly in your solution by adding it to the solution package.

In solution explorer, double click on Package.

In the Package properties select the Advanced tab

Add the assembly in Additional Assemblies

0
votes

If you are trying to access this library inside inline code in an ASPX page (e.g. between <% and %> tags), then you'll need to add a reference to the assembly in the web.config so when the page is compiled on demand, the compiler will reference it.

<compilation debug="true">
  <assemblies>
    <add assembly="EPPlus, Version=3.1.3.0, Culture=neutral, ..." />