1

I am trying to use ClosedXML to produce excel documents within an application, however, Whenevet I try to run it I receive a could not load file or assembly server error.

This is my form application my form

This is my Package my Package

and this is my error when I click the import file button

error

ahmedshpt
  • 23
  • 1
  • 6
  • Which file or assembly can't it load? – rickvdbosch Nov 29 '18 at 15:03
  • What do you mean you don't know? If you're getting that exception, it at least specifies the starting point of the exception right? – rickvdbosch Nov 29 '18 at 15:33
  • i'm so sorry I'm a beginner in asp.net Could not load file or assembly 'ClosedXML, Version=0.94.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044) – ahmedshpt Nov 29 '18 at 16:10
  • @ahmedshpt ClosedXML recently changed from being a strong-named assembly to being not strong-named. This could be part of the problem. I suggest you remove all package references and re-add them. If you still want the strong-named version of ClosedXML, use the ClosedXML.Signed NuGet package. – Francois Botha Dec 05 '18 at 09:47

1 Answers1

1

Since you're developing for SharePoint, all used assemblies need to be strongly-named. They are deployed in the GAC, which is only possible for signed assemblies.

More info in this post: https://sharepoint.stackexchange.com/questions/62242/gac-and-signing-assembly-with-strong-name

You can change the NuGet reference to be ClosedXml.Signed, the signed version of ClosedXml.

rickvdbosch
  • 14,105
  • 2
  • 40
  • 53
  • thanks rickvdbosch : i change the reference to ClosedXml.Signed but nothing changed can you help me please – ahmedshpt Nov 30 '18 at 08:30
  • You should give some more relevant information. What error are you getting? – rickvdbosch Nov 30 '18 at 08:34
  • Could not load file or assembly 'ClosedXML, Version=0.93.1.0, Culture=neutral, PublicKeyToken=fd1eb21b62ae805b' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) – ahmedshpt Nov 30 '18 at 09:29
  • You should probably remove the explicit `ClosedXML` reference, Clean the solution, add the `ClosedXML.Signed` reference. Then rebuild the solution and try that again. Also, if you're deploying to another machine for testing, make sure you remove everything there before deploying the new version. – rickvdbosch Nov 30 '18 at 09:40
  • thanks rickvdbosch i install closedxml.signed but same error – ahmedshpt Nov 30 '18 at 10:07