Could not load file or assembly

0

I am getting this error on live server when I create a excel file with format xlsx, while on local server its working fine. I had used DocumentFormat.OpenXml and ClosedXML library. Please help me to solve this issue. This is my code.

 using (XLWorkbook wb = new XLWorkbook())
            {
                wb.Worksheets.Add(dtAgentQuery);
                wb.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
                wb.Style.Font.Bold = true;

                Response.Clear();
                Response.Buffer = true;
                Response.Charset = "";
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.AddHeader("content-disposition", "attachment;filename=GTFKushmha.xlsx");

                using (MemoryStream MyMemoryStream = new MemoryStream())
                {
                    wb.SaveAs(MyMemoryStream);
                    MyMemoryStream.WriteTo(Response.OutputStream);
                    Response.Flush();
                    Response.End();
                }
            }

Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.7.2.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

c#
asp.net
asked on Stack Overflow Dec 30, 2019 by Nischal Tyagi

1 Answer

1

The library differs between local server and live server. (other version, architecture)

You should deliver the assembly (DLL) you used in your development with the application. Check for options to do that with your IDE.

answered on Stack Overflow Dec 30, 2019 by tux1337

User contributions licensed under CC BY-SA 3.0