EPplus组装错误

Sha*_*der 2 .net asp.net epplus

我正在使用asp.net 4.5框架。我刚刚使用NUget Package下载了EPPLus。然后,我使用了以下链接中给出的代码。

http://epplus.codeplex.com/wikipage?title=Webapplication示例

并在按钮的单击事件上添加以下代码。单击按钮后,我得到以下错误。

无法加载文件或程序集'EPPlus,版本= 3.1.3.0,区域性=中性,PublicKeyToken = ea159fdaa78159a1'或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。(来自HRESULT的异常:0x80131040)

如果我犯了任何愚蠢的错误,请提出建议。

在此处输入图片说明

DataTable table = new DataTable();
table.Columns.Add("Dosage", typeof(int));
table.Columns.Add("Drug", typeof(string));
table.Columns.Add("Patient", typeof(string));
table.Columns.Add("Date", typeof(DateTime));

table.Rows.Add(25, "Indocin", "David", DateTime.Now);
table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now);
table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now);
table.Rows.Add(21, "Combivent", "Janet", DateTime.Now);
table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now);

using (ExcelPackage pck = new ExcelPackage())
{
    //Create the worksheet
    ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Demo");

    //Load the datatable into the sheet, starting from cell A1. Print the column names on row 1
    ws.Cells["A1"].LoadFromDataTable(table, true);

    //Format the header for column 1-3
    using (ExcelRange rng = ws.Cells["A1:C1"])
    {
        rng.Style.Font.Bold = true;
        rng.Style.Fill.PatternType = ExcelFillStyle.Solid;                      //Set Pattern for the background to Solid
        rng.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(79, 129, 189));  //Set color to dark blue
        rng.Style.Font.Color.SetColor(Color.White);
    }


    //Write it back to the client
    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
    Response.AddHeader("content-disposition", "attachment;  filename=ExcelDemo.xlsx");
    Response.BinaryWrite(pck.GetAsByteArray());
}
Run Code Online (Sandbox Code Playgroud)

Bro*_*nek 5

我遇到了一个案例,其中我的解决方案是为测试目的而准备的,并且由几个引用EPPlus的项目组成。问题是我仅将Ver 4引用到一个项目,而其他项目则保留了旧版本的EPPlus(尤其是可执行文件具有较旧的版本)。结果是,在构建过程之后,该文件夹包含较旧的EPPlus,并且在运行时我将链接的项目与较新的EPPlus一起使用(因此该项目无法找到正确的EPPlus版本)。在我将相同版本的EPPlus引用到所有项目之后,不再抛出异常。