BadImageFormatException C# [duplicate]

Solution 1:

Make sure that you are not having 32-bit / 64-bit conflict.

Refer this question:

Troubleshooting BadImageFormatException

If you're running on a 64-bit OS, the Assembly RevitAPI may be compiled as 32-bit and your process as 64-bit or "Any CPU".

Or, the RevitAPI is compiled as 64-bit and your process is compiled as 32-bit or "Any CPU" and running on a 32-bit OS.