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

Graph SDK v5 referring to Microsoft.Kiota.Abstractions, Version=1.2.1.0 #2177

Closed
kyzhangZao opened this issue Oct 23, 2023 · 34 comments
Closed
Labels
Question: SDK Status: No recent activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close

Comments

@kyzhangZao
Copy link

I'm trying to upgrade our service to use graph sdk v5.
However, mock GraphServiceClinet using this new sdk causing:

System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Kiota.Abstractions, Version=1.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

per my understanding, graph sdk5 and graph.core sdk3, should be using Microsoft.Kiota.Abstractions, Version=1.3.1.0, not 1.2.1.0
I'm not sure why Microsoft.Kiota.Abstractions, Version=1.2.1.0 would be involved here. Also, this error is not occuring when using graph sdk4+graph.core sdk2.

Any idea why this happen and how to fix?

@andrueastman
Copy link
Member

Thanks for raising this @kyzhangZao

Any chance you can confirm the version of the SDK you are using as well as the dotnet runtime as well when you experience this?

@kyzhangZao
Copy link
Author

We're using .NET Framework 4.7.2
sdk Microsoft.Graph 5.30.0 and Microsoft.Graph.Core 3.0.11

@baywet
Copy link
Member

baywet commented Oct 24, 2023

MSGraph 5.30.0 depends on graph core 3.X which at the time of the issue resolved to 3.0.11.
Graph Core 3.0.11 depends on both abstractions 1.3.1 and serialization json 1.0.8
Serialization JSON depends on abstractions 1.2.1

We've just released graph 5.31.0 and graph core 3.1.0 which aligns all dependencies. Would you mind trying with those new versions?

Also do you have any other kiota client in your code base?

@kyzhangZao
Copy link
Author

We do not have any explicit reference to kiota client. Per my understanding, we just introduced this when try to use newer version of graph sdk.
I just quickly tried to use graph 5.31.0 and graph core 3.1.0, however seems graph core 3.1.0 depends on Microsoft.Kiota.Abstractions 1.5.0, however the unit test is now trying to refer to Microsoft.Kiota.Abstractions 1.3.1.0

Could not load file or assembly 'Microsoft.Kiota.Abstractions, Version=1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.

While when I try to explicitly adding dependency of Microsoft.Kiota.Abstractions, Version=1.3.1.0 to our unit test (which I suppose we should not directly adding that dependency), gets the below error

Install-Package : NU1605: Warning As Error: Detected package downgrade: Microsoft.Kiota.Abstractions from 1.5.0 to 1.3.1. Reference
the package directly from the project to select a different version.

And we do not have any other reference to koita client
image

@baywet
Copy link
Member

baywet commented Oct 24, 2023

Is it possible you have multiple references to graph or graph core in your project structure?

@kyzhangZao
Copy link
Author

image
The above are the only references we have to graph and graph core.

@baywet
Copy link
Member

baywet commented Oct 24, 2023

Can you run the dotnet list package command to try to understand which dependency is bringing the older version of abstractions?
https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-list-package

@kyzhangZao
Copy link
Author

That's the two places we have graph sdk and graph core sdk
image
image
And that the project where unit tests fail:
image

@baywet
Copy link
Member

baywet commented Oct 25, 2023

Thanks for the additional information:

  • which project does the test project have a dependency on? common? or cloud common?
  • can you try removing the reference to graph core in cloud common? dotnet remove <pathToCsProj> package microsoft.graph.core
  • does cloud common have a dependency on common? or the other way around?

@kyzhangZao
Copy link
Author

kyzhangZao commented Oct 25, 2023

  • Test project has direct dependency on cloud common, and indirect dependency on common.

  • Cloud common and common does not have dependency on each other. They have a common dependency on another project
    image

  • I tried to remove dependency on graph.core and it gets back to error

System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Kiota.Abstractions, Version=1.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Meanwhile I'm not sure if removing this dependency would actually work because in our development, there is another use case explicitly stating we should use graph.core sdk

@A-Lynch
Copy link

A-Lynch commented Oct 25, 2023

I'm experiencing the same issue and have cleared nuget cache, the issue still exists

@baywet
Copy link
Member

baywet commented Oct 25, 2023

@A-Lynch are you also developing an application using .net framework (4.X)? or are you on dotnet core? (5/6/7)

@A-Lynch
Copy link

A-Lynch commented Oct 25, 2023

Hi 4.8

@baywet
Copy link
Member

baywet commented Oct 25, 2023

thanks for the additional information. And are you using the dotnet cli to build or visual studio?

@A-Lynch
Copy link

A-Lynch commented Oct 25, 2023 via email

@andrueastman
Copy link
Member

@A-Lynch @kyzhangZao Any chance you are able to replicate the issue with the latest release?https://www.nuget.org/packages/Microsoft.Graph/5.32.0

@A-Lynch
Copy link

A-Lynch commented Oct 26, 2023

Hi

Ive updated, however I now have an issue with Azure Core

Tried the usual - Clean, Delete obj & bin folders

TypeInitializationException: The type initializer for 'Azure.Core.ClientOptions' threw an exception.

FileNotFoundException: Could not load file or assembly 'System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.

@kyzhangZao
Copy link
Author

I tried the same, also tried to use graph 5.32.0, still seeing

System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Kiota.Abstractions, Version=1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

@A-Lynch
Copy link

A-Lynch commented Oct 26, 2023

Sorry Further testing has reviled an issue with

Microsoft.Identity.Client 4.57 is installed as part of adding package, yet it references Microsoft.Identity.Client 4.56
This is the same for the Microsoft.IdentityModel. libraries

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.Identity.Client, Version=4.56.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae
(Fully-specified)
LOG: Initial PrivatePath = NULL
Calling assembly : Azure.Identity, Version=1.10.3.0, Culture=neutral, PublicKeyToken=92742159e12e44c8Version=1.10.3.0, Culture=neutral, PublicKeyToken=92742159e12e44c8.

@kyzhangZao
Copy link
Author

@baywet I tried to ask my teammates to run on their end as you suggested offline, but they're getting the same exception as the ones on my end.

@baywet
Copy link
Member

baywet commented Oct 26, 2023

Thanks everyone for the additional information.
Can you confirm which version of Visual Studio you're using? I took the time to get a VM with VS 2022 version 17.7.6, which looks like it's the latest version for the mainline.
(and I'm still not getting the issue)
@kyzhangZao could you reach out internally with the setup instructions for the integration tests for your repo? I want to make sure this missing setup is not hiding the issue on my side.

@A-Lynch
Copy link

A-Lynch commented Oct 26, 2023

Hi

Im using

Microsoft Visual Studio Professional 2022 (64-bit) - Current
Version 17.6.4

@baywet
Copy link
Member

baywet commented Oct 26, 2023

Thanks for the additional information.
Since @kyzhangZao is also a Microsoft employee, we just spent some time troubleshooting the issue together.
Now that the dependencies alignment issue has been solved for kiota abstractions, my guess was that version ranges (like in kiota http for System.Diagnostics.DiagnosticSource) were confusing this older version.
We've tried a couple of combinations to understand why the dependency could not be loaded by net472.
Unfortunately our multiple tries, including locking the dependency to a specific version instead of a range, we unsuccessful.
The next step is for @kyzhangZao to engage with the dotnet team to understand this assembly loading issue better.

@baywet
Copy link
Member

baywet commented Nov 1, 2023

@A-Lynch as a recap from the internal discussions: the problem was solved for the internal service by switching to CPM which helps resolve any conflict.
Of course, if you can, it'd be preferrable to migrate to dotnet core. Not only the dependency resolution works better, but you'll benefit from huge performance improvements and much more.

@kyzhangZao
Copy link
Author

Hi @baywet , just to provide an update there, using CPM tool as mentioned above actually removed some of our setup configs. Ans when I try to add back those config, new conflicts showed up.
So I created a clean branch with changes that is able to build without error. UTs now fails with

System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Kiota.Abstractions, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) ---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Kiota.Abstractions, Version=1.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I'm currently on sdk 5.34.0
I might need more help with simply focusing on resolve that specific dependency issue. Thanks.

@baywet
Copy link
Member

baywet commented Nov 15, 2023

For everybody else involved: we're working with the dotnet team to understand whether or not CPM can be used in combination with assembly binding redirection. Also to understand whether CPM can be used for some projects and not others.

@andrueastman andrueastman removed their assignment Apr 3, 2024
@gallettoNL
Copy link

@baywet , I'm experiencing similar issues with kiota packages and Graph. What's the outcome for this?
Cheers,
Will de Haan

Found conflicts between different versions of "Microsoft.Kiota.Abstractions" that could not be resolved.
41>C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2412,5): warning MSB3277: There was a conflict between "Microsoft.Kiota.Abstractions, Version=1.13.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" and "Microsoft.Kiota.Abstractions, Version=1.14.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35".

@baywet
Copy link
Member

baywet commented Nov 13, 2024

Thanks for the nudge here.

The gist of the conversation was that CPM and assembly binding redirections can be used in combination, but it's easy to get things wrong.

To investigate which project pulls what (at dev time), make heavy use of the new dotnet nuget why command documentation

On our side we've taken a few steps to make this easier:

  • Aligned all the kiota packages versioning, and release them at the same time.
  • Introduced a new kiota bundle package to reduce the number of direct dependencies a project needs to take.
  • Switched to version ranges in kiota packages for things like System.Text.Json, and in Graph packages for kiota packages.

Start by making sure you're on the latest version of the Graph SDK, and that you don't have any direct dependency on outdated graph core/kiota dependencies. And investigate further with dotnet nuget why if needed.

Let us know if you have any additional comments or questions.

@baywet baywet added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed Needs: Attention 👋 labels Nov 13, 2024
@gallettoNL
Copy link

gallettoNL commented Nov 13, 2024 via email

@gallettoNL
Copy link

gallettoNL commented Nov 13, 2024 via email

@gallettoNL
Copy link

gallettoNL commented Nov 13, 2024 via email

@baywet
Copy link
Member

baywet commented Nov 13, 2024

The error messages you've provided refer to 3 different versions: 1.12.3, 1.13.0, 1.14.0.
My guess is that one or more of your project refers to different versions of the Graph SDK, or kiota dependencies, or both.
I'd suggest you track dependencies in all csproj files, to better understand who is pulling what, and resolve any misalignment in your project configurations.

Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question: SDK Status: No recent activity status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close
Projects
None yet
Development

No branches or pull requests

5 participants