pnp / PnP-Sites-Core

Microsoft 365 Dev PnP Core component (.NET) targeted for increasing developer productivity with CSOM based solutions.
Other
415 stars 644 forks source link

Could not load file or assembly 'Microsoft.Graph.Core, Version=1.9.0.0' #2548

Open vman opened 4 years ago

vman commented 4 years ago

Category

[x] Bug [ ] Enhancement

Environment

[x] Office 365 / SharePoint Online [ ] SharePoint 2016 [ ] SharePoint 2013

Expected or Desired Behavior

Able to use latest Graph .NET Core SDK 1.21.0 together with PnP Sites Core 3.18.2002 in the same Azure Functions project.

Observed Behavior

Currently, the latest PnP Sites Core 3.18.2002 seems to have a hard dependency on Microsoft.Graph.Core 1.9.0.0

This is very similar to https://github.com/SharePoint/PnP-Sites-Core/issues/1666 but with different versions of Microsoft.Graph and Microsoft.Graph.Core

Error is thrown when doing ProvisioningTemplate template = provider.GetTemplate("MySchema.xml");

image

image

Getting the error: Could not load file or assembly 'Microsoft.Graph.Core, Version=1.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.":"Microsoft.Graph.Core, Version=1.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"}

Steps to Reproduce

1) Create a new Azure Functions .NET Framework project 2) Use the latest nuget package for PnP sites core 3.18.2002 along with PnP Schema Version 202002 3) Use the recent Microsoft.Graph 1.21 package in the same Azure Functions project to do some operations on the graph. 4) When the code hits ProvisioningTemplate template = provider.GetTemplate("MySchema.xml");, it throws the error.

Thanks for your contribution! Sharing is caring.

ghost commented 4 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

WardWilmsen commented 4 years ago

Having the exact same issue in my azure functions project, using binding redirects for these packages doesn't help either. It keeps asking for those 1.9.0.0 versions.

evobis commented 4 years ago

I am experiencing the exact same issue. The issue seems to be occuring if you are using both "SharePointPnPCoreOnline" and "Microsoft.Graph" nuget packages in the same project.

WardWilmsen commented 4 years ago

I am experiencing the exact same issue. The issue seems to be occuring if you are using both "SharePointPnPCoreOnline" and "Microsoft.Graph" nuget packages in the same project.

I downgraded all my other dependent nuget packages until I could install Microsoft.Graph 1.9.0.0. This fixed it for me.

evobis commented 4 years ago

I am experiencing the exact same issue. The issue seems to be occuring if you are using both "SharePointPnPCoreOnline" and "Microsoft.Graph" nuget packages in the same project.

I downgraded all my other dependent nuget packages until I could install Microsoft.Graph 1.9.0.0. This fixed it for me.

That isn't a possible solution for me. I am using some of the newest features in Microsoft.Graph directly and therefore need the newest version of graph as well as PNP. I ended up creating two separate functions. One as a time triggered function that only used PNP and one as a HTTP triggered function which is called from the time trigger function, that only used the Microsoft.Graph part directly. A bit of a hack, but it worked...

vman commented 4 years ago

My current workaround is to use a completely different function app for SharePointPnPCoreOnline which is based on .NET framework while all of the Graph and other functionality lives in a different function app based on .NET Core. Any communication between the function apps is done through queue messages. Not ideal but works for the time being.

paalnym commented 4 years ago

Had the same problem, my loader exception was: Could not load file or assembly 'Microsoft.Graph, Version=1.14.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. Seems like PnPCore installs one version of MS Graph, but references another. I downgraded MS Graph to 1.14.0.0 and now all works as expected.