Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReflectionTypeLoadException: Could not load file or assembly 'Microsoft.OData.Core' #886

Open
aureole82 opened this issue Dec 20, 2022 · 6 comments

Comments

@aureole82
Copy link

Using NuGet package Simple.OData.V4.Client 6.0.1 I get the following exception on every request:

System.InvalidOperationException
  HResult=0x80131509
  Message=Unable to load OData adapter from assembly Simple.OData.Client.V4.Adapter
  Source=Simple.OData.Client.Core
  StackTrace:
   at Simple.OData.Client.ODataAdapterFactory.LoadModelAdapter(ITypeCache typeCache, String modelAdapterAssemblyName, String modelAdapterTypeName, Object[] ctorParams)
   at Simple.OData.Client.ODataAdapterFactory.<>c__DisplayClass11_0.<GetModelAdapterLoader>b__1()
   at Simple.OData.Client.ODataAdapterFactory.CreateAdapterLoader(String metadataString, ITypeCache typeCache)
   at Simple.OData.Client.EdmMetadataCache.GetODataAdapter(ISession session)
   at Simple.OData.Client.Session.<Initialize>d__19.MoveNext()
   at Simple.OData.Client.Session.<ResolveAdapterAsync>d__22.MoveNext()
   at Simple.OData.Client.ODataClient.<FindEntryAsync>d__92.MoveNext()
   at Simple.OData.Client.FluentClientBase`2.<FilterAndTypeColumnsAsync>d__98.MoveNext()
   at Program.<<Main>$>d__0.MoveNext() in C:\Sources\ConsoleApp1\ConsoleApp1\Program.cs:line 13

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load file or assembly 'Microsoft.OData.Edm, Version=7.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.OData.Core, Version=7.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.OData.Core, Version=7.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.OData.Core, Version=7.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.OData.Core, Version=7.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.OData.Core, Version=7.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.OData.Core, Version=7.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.OData.Core, Version=7.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.OData.Core, Version=7.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.OData.Core, Version=7.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.OData.Core, Version=7.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.OData.Core, Version=7.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.OData.Core, Version=7.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

Solution:
You should add Microsoft.OData.Core as dependency. (At least adding this manually fixes the issue on my machine).

@NoahStolk
Copy link

We are also running into this problem since upgrading to 6.0.1. From our packages.lock.json file:

"Simple.OData.Client": {
  "type": "Direct",
  "requested": "[6.0.1, )",
  "resolved": "6.0.1",
  "dependencies": {
    "Microsoft.Data.OData": "[5.8.5, 6.0.0)",
    "Microsoft.OData.Core": "[7.9.4, 8.0.0)"
  }
},
"Microsoft.OData.Core": {
  "type": "Transitive",
  "resolved": "7.9.4",
  "dependencies": {
    "Microsoft.Bcl.AsyncInterfaces": "5.0.0",
    "Microsoft.OData.Edm": "[7.9.4]",
    "Microsoft.Spatial": "[7.9.4]"
  }
},
"Microsoft.OData.Edm": {
  "type": "Transitive",
  "resolved": "7.9.4",
  "dependencies": {
    "System.Runtime.CompilerServices.Unsafe": "4.6.0",
    "System.Text.Encodings.Web": "4.7.2",
    "System.Text.Json": "4.6.0"
  }
},

It seems version 7.9.4 is resolved but 7.10.0 is requested by the runtime. For now, we will be applying the same workaround as mentioned. (Adding a direct package dependency to make sure the correct version is resolved and pinning the version number.)

<PackageReference Include="Microsoft.OData.Core" Version="[7.10.0]" />

@giarico
Copy link

giarico commented Jan 31, 2023

I can't understand why this is not already solved after 3 months.
Without this workaround nothing works.

Is this project still alive??

@stefankaufmann
Copy link

I got so frustrated of this fix, that I created a Pull Request. Would be awesome, if you can provide a new nuget package containing the fix. Thanks.

@esbenbach
Copy link

@davidnmbond you are the only recent contributor in the commits history.
Do you have the power/permissions to approve and merge the PR opened by @stefankaufmann ?

@robertgro
Copy link

Pushing this, because resolving the issue and merging the PR are still in pending state.

@GerkinDev
Copy link

Had the same problem. I managed to work around it by explicitly specifying the version I want of the transitive dependency.

In csproj:

    <PackageReference Include="Microsoft.OData.Core" Version="7.10.0" />
    <PackageReference Include="Microsoft.OData.Edm" Version="7.10.0" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants