+1  A: 

Looks like goBIM_API or one of its references are 32 bit. If you have any assembly marked x86 it will not load into a x64 assembly.

Adam Driscoll
That's what I thought, but I've checked every assembly, and used Dependency Walker to check everything is x64. Everything checks out as x64. If I take the serialization bit out of the code, the rest of the code (with other objects created from goBIM_API.dll), runs fine. It seems to be thrown only with Serialization.
ikeo
@ikeo: Is goBIM_API.dll your own dll?
0xA3
Definitely look at the Fusion log as suggested by the comments. It might give you more insight into where it's loading assemblies. You may be loading an assembly you are not expecting.
Adam Driscoll
Yep. goBIM_API.dll is my own.
ikeo
A: 

It looks as if you are using a third-party library (goBIM_API.dll) which is only present as a 32-bit version. You get the exception because this 32-bit assembly cannot be loaded into 64-bit process.

To fix this problem, either get a 64-bit version of that library, or, what is easier, set the target platform to x86 for all your executables.

Using x86 on a 64-bit platform usually should not have any noticeable performance hit. The only downside is that you can't get above the 2GB/3GB memory limit of a process.

Update:

Is AutoDesk Revit a 32-bit application? That's what it looks like. Then you will have to compile your libary using the x86 platform target to fix the error.

0xA3
I've compiled a 64bit version of the library, and still get this error, as mentioned above.
ikeo
A: 

Did you compile the DLL using Multi-threaded (/MT) so that all dependencies are put in the binary of your DLL?

darkstar3d
A: 

Because the serializer was being called in a method called by another process, the goBIM_API.dll needed to be located in the same directory as that processes' executable. After moving the .dll to that location, serialization works fine.

ikeo