Page 1 of 1

[V2] Could not load file or assembly System.Numerics.Vectors

Posted: Wed Feb 20, 2019 8:38 am
by AlexCereus
Hello.

I try to use BepuPhysics with Photon Server. When I run my app, it logs error:

ERROR Photon.SocketServer.ApplicationBase [(null)] - System.BadImageFormatException: Could not load file or assembly 'System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)

Please help.

Re: [V2] Could not load file or assembly System.Numerics.Vectors

Posted: Wed Feb 20, 2019 11:32 am
by KakCAT
Hi Alex,

I don't know if this is the case, but BadImageFormatException is very often a problem when mixing 32 bits and 64 bits:

https://stackoverflow.com/questions/159 ... on-c-sharp

Re: [V2] Could not load file or assembly System.Numerics.Vectors

Posted: Thu Feb 21, 2019 12:11 am
by Norbo
In .NET standard projects, nuget sometimes pulls down 'dummy' dependencies. They provide the same API as the full implementation and provide all the same reflection features but don't contain any implementation details. When a .NET Standard project is consumed by an application, the application project pulls down non-dummy dependencies specific to the application's framework.

In this case, it looks like the dummy dependencies are being directly referenced and the runtime is unhappy about it. You'll need to find a compatible version of the dependency to use. VS's package manager will automatically resolve this sort of thing, but if you're working outside the package manager you'll have to do it manually.