Why do I get "Could not load file or assembly EasyXLS" error?
The following error might occur at runtime when using EasyXLS Excel library:
Could not load file or assembly 'EasyXLS, Version=8.6.0.0, Culture=neutral, PublicKeyToken=632c31013494909a' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Possible reason #1: Windows 64-bit, Visual Studio project and EasyXLS.dll for 32-bit
If the EasyXLS version for 32-bit is used on a Windows 64-bit operating system, check the project properties and make sure that the target machine is set to x86.
Check the project properties and make sure that on the Build tab, the Platform Target is set to x86 and not Any CPU or x64.
Check the project properties and make sure that on the Compile tab, Advanced Compile Options, Target CPU is set to x86 and not Any CPU or x64.
Check the project properties and make sure that on the Configuration Properties node, Linker, Advanced, the Target Machine is set to x86.
Possible reason #2: Visual Studio project and EasyXLS.dll for 64-bit
If the EasyXLS version for 64-bit is used, check the project properties and make sure that the target machine is set to x64 or Any CPU for a Windows 64-bit operating system.
EasyXLS.dll for 64-bit cannot run on Windows 32-bit operating system. EasyXLS.dll for 32-bit must be used at runtime.
Check the project properties and make sure that on the Build tab, the Platform Target is to x64 or Any CPU.
Check the project properties and make sure that on the Compile tab, Advanced Compile Options, Target CPU is set to x64 or Any CPU.
Check the project properties and make sure that on the Configuration Properties node, Linker, Advanced, the Target Machine is set to x64.
Possible reason #3: Windows 64-bit, IIS Server (web application) and EasyXLS.dll for 64-bit
If the EasyXLS version for 64-bit is used on a Windows 64-bit operating system, make sure that IIS allows running of 64-bit applications.
Open Internet Information Services (IIS) Manager on Control Panel/Administrative Tools. Select Application Pools and the application pool associated with your web application.
Select Advanced Settings and check if Enable 32-bit Application option is set to false.
If running from Visual Studio environment, be sure that the application pool and platform target settings are matching (see Possible reason #1 and Possible reason #2 for details).
Possible reason #4: Windows 64-bit, IIS Server (web application) and EasyXLS.dll for 32-bit
If the EasyXLS version for 32-bit is used on a Windows 64-bit operating system, make sure that IIS allows running of 32-bit applications.
Open Internet Information Services (IIS) Manager on Control Panel/Administrative Tools. Select Application Pools and the application pool associated with your web application.
Select Advanced Settings and check if Enable 32-bit Application option is set to true.
If running from Visual Studio environment, be sure that the application pool and platform target settings are matching (see Possible reason #1 and Possible reason #2 for details).
Possible reason #5: Visual Studio Development Server (web application) and EasyXLS.dll for 64-bit
If the EasyXLS version for 64-bit is used in a web application that uses Visual Studio Development Server as web server, the error occurs because Visual Studio Development Server always run on 32-bit.
Possible solutions are:
I) Use EasyXLS.dll 32-bit
II) Go to project properties, Web tab and check "Use Local IIS Web server" and configure IIS server to support 64-bit applications (see Possible reason #3).
Possible reason #6: Visual Studio, IIS Express (web application) and EasyXLS.dll for 64-bit
If the EasyXLS version for 64-bit is used in a web application that uses IIS Express as web server, the error occurs because IIS Express runs on 32-bit by default.
To check if Visual Studio is using IIS Express to run your web page, go to project properties, Web tab and check Servers section:
Possible solutions are:
Go to Tools, Options, Projects and Solutions, Web Projects and check "Use the 64 bit version of IIS Express" (for Visual Studio 2013 or later)
Use EasyXLS.dll 32-bit
Go to project properties, Web tab, check "Use Local IIS Web server" and configure IIS server to support 64-bit applications (see Possible reason #3).
Go to project properties, Web tab and unselect the checkbox "Use IIS Express"
Run the 64-bit IIS Express by executing the following command manually: