System.BadImageFormatException An attempt was made to load a program with an incorrect format

It’s possibly a 32 – 64 bits mismatch. 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.