vpenades / SharpGLTF

glTF reader and writer for .NET Standard
MIT License
478 stars 75 forks source link

Could not load file or assembly System.Numeric.Vectors exception #4

Closed Imaver closed 5 years ago

Imaver commented 5 years ago

Could you please kindly solve the issue with the dependencies? I have it reproduced after successfully installed NuGet packages and trying to run the program. This is a runtime error, the project compiles successfully.

Could not load file or assembly 'System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

vpenades commented 5 years ago

Which version of SharpGLTF are you using? Which framework are you targeting? I suspect NetFramework 4.6 or 4.7? Is your csproj old style, or the new SDK style?

You can try one of those solutions:

https://github.com/dotnet/corefx/issues/30106#issuecomment-395185748

Let me know if it solves your issue

Imaver commented 5 years ago

Thank you for such a quick reply!

SharpGLTF version 1.0.0-alpha007 Framework 4.7.1 also just reproduced the difficulty with 4.7.2 old style of the csproj

Thank you for the solutions link, I've tried them previously I will double check them again now. Keep you updated

vpenades commented 5 years ago

I've just created a console app test project, old style, targeting net471 and it seems to be working fine.

I've seen similar issues when the main application, or another dependency, is also using System.Numerics.Vectors, or even worse, a different version of system.Numerics.Vectors.... in that case, the first dependency that needs System.Numerics.Vectors loads it successfully, and all others fail.

This all happens because old style csproj arranges the dependencies to require the exact version match.

New SDK csproj is more friendly about dependencies, so, if it's possible for you to switch to new SDK csproj style, it might solve your problem.

Imaver commented 5 years ago

vpenades, Thank you very much for the useful link and for the extensive explanation.

In my specific case, I needed to include a dependent assembly configuration in the starting project. If the same configuration is applied in a newly created library with SharpGltf referenced that was part of the solution - it didn't work.

So in case somebody experiences something similar - make sure that dependendAssembly is configured correctly in your starting project inside. App.config file

Use this example:

`

    <bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
  </dependentAssembly>`
vpenades commented 5 years ago

Hi @Imaver

I've just uploaded new packages of SharpGLTF. I while ago I realized that Net.Standard 2,0 allows for implicit System.Numeric.Vectors dependency, so there's no need to explicitly reference system.numerics vectors.

You can try the latest packages (Alpha0008) and see if it solves your problem.

Imaver commented 5 years ago

Hi @vpenades, Thank you very much for keeping me up to date! I will check the new version