Get Spreadsheetlight working

Spreadsheetlight is a dotnet library for creating Excel documents with all it’s wonderful features. The Spreadsheetlight nuget has no dependencies on nuget packages, but does have a dependency on Open XML SDK 2.0. This can be installed with the DocumentFormat.OpenXml 1.0.0 nuget.

But after a while everything stopped working, because you tried updating the DocumentFormat.OpenXml to the latest version 2.5.0.

An unhandled exception of type ‘System.TypeLoadException’ occurred.
Additional information: Could not load type ‘DocumentFormat.OpenXml.Spreadsheet.SmartTags’ from assembly ‘DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’.

or

An unhandled exception of type ‘System.IO.FileLoadException’ occurred.
Additional information: Could not load file or assembly ‘DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference.

Solution

  1. Revert back to DocumentFormat.OpenXml version 1.0.0
    Install-Package DocumentFormat.OpenXml -Version 1.0.0
    
  2. Remove the assemblyBinding from the app.config
    <configuration>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <!-- Remove dependentAssembly for DocumentFormant.OpenXml -->
          <dependentAssembly>
            <assemblyIdentity name="DocumentFormat.OpenXml" publicKeyToken="31bf3856ad364e35" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-2.5.5631.0" newVersion="2.5.5631.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    </configuration>
    
Unknown's avatar

About erictummers

Working in a DevOps team is the best thing that happened to me. I like challenges and sharing the solutions with others. On my blog I’ll mostly post about my work, but expect an occasional home project, productivity tip and tooling review.
This entry was posted in Development and tagged , , , , . Bookmark the permalink.

18 Responses to Get Spreadsheetlight working

  1. Scott Lister's avatar Scott Lister says:

    Thank you so much this worked like a charm. I figured out that I needed to revert the version of the OpenXML and I did that but I was really banging my head against the wall trying to figure out that second manifest error message. Thanks again.

  2. Maxence's avatar Maxence says:

    Thanks!!! You saved my life.

  3. laserlab's avatar laserlab says:

    Thanks..!!

  4. Thank you Eric! Works great.

  5. Francisco Vera's avatar Francisco Vera says:

    Thank you, now I can continue with my job.

  6. Harish's avatar Harish says:

    Thanks man…!!!

  7. Emil's avatar Emil says:

    Got it to work with your help thanks!

  8. Rafik's avatar Rafik says:

    Thanks MAAAAAAAAAAAAAAAAAAAN

  9. planetregin's avatar planetregin says:

    Thank you! Thank you! Thank you! Saved quite a lot of frustration. 🙂

  10. Juan Bolanos's avatar Juan Bolanos says:

    Hey Thanks a lot Eric! you saved my day!

  11. Wilson's avatar Wilson says:

    thanks eric so much!

  12. Anh Lân's avatar Anh Lân says:

    You saved the day, sir. Thank you!

  13. Ni's avatar Ni says:

    Thank you, you saved my work

Leave a reply to Maxence Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.