locked
Could not load file or assembly 'ClosedXML' or one of its dependencies. RRS feed

  • Question

  • my code is running perfect on framework 4.5 but when i write same code in 3.5 for export data from data table in excel then i get below error. please give right solution.

    i am also using

    closedxml.dll

    documentFormat.openxml 2.0

    System.Web.Extensions.Design

    System.Web.Extensions 

    Could not load file or assembly 'ClosedXML' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.BadImageFormatException: Could not load file or assembly 'ClosedXML' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Assembly Load Trace: The following information can be helpful to determine why the assembly 'ClosedXML' could not be loaded.
    
    

    Wednesday, August 19, 2015 6:18 PM

Answers

  • The assembly ClosedXML you're using was built using a higher version of CLR. You can't use a .NET 4 assembly on a .NET 3.5 environment.

    According to the ClosedXML's CodePlex page, there's a .NET 3.5 version of the dll. Download that and use it instead.

    • Proposed as answer by CoolDadTx Thursday, August 20, 2015 2:08 PM
    • Marked as answer by Kristin Xie Friday, August 28, 2015 8:02 AM
    Wednesday, August 19, 2015 7:07 PM