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>
    

About erictummers

My work as a recruited developer changes almost every month. 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.

16 Responses to Get Spreadsheetlight working

  1. 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 says:

    Thanks!!! You saved my life.

  3. laserlab says:

    Thanks..!!

  4. Thank you Eric! Works great.

  5. Francisco Vera says:

    Thank you, now I can continue with my job.

  6. Harish says:

    Thanks man…!!!

  7. Emil says:

    Got it to work with your help thanks!

  8. Rafik says:

    Thanks MAAAAAAAAAAAAAAAAAAAN

  9. planetregin says:

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

  10. Juan Bolanos says:

    Hey Thanks a lot Eric! you saved my day!

  11. Wilson says:

    thanks eric so much!

  12. Anh Lân says:

    You saved the day, sir. Thank you!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s