0

I have an azure function that calls a static method from a DLL I created separately and uploaded to the function folder, along with all of its dependencies (all dll's from the release folder were uploaded to the azure function).

When i try to call the function i receive an error Could not load file or assembly 'Microsoft.SharePoint.Client.Runtime, Version=16.1.3912.1204

If i upload this version of Microsoft.SharePoint.Client.Runtime, i receive an error that it wants the other version again: Could not load file or assembly 'Microsoft.SharePoint.Client.Runtime, Version=16.0.0.0

How can this be? It runs successfully outside Azure. Why does it want two versions of the same DLL? The project references 16.1.3912.1204, and this is the version of the dll in the \bin\release folder.

Side note: my .NET GAC folder contains version 16.0.0.0. If it is the case that for some reason inside the Microsoft.SharePoint.Client dll's it needs to reference both versions, how can i include two versions of the same file in an azure function?

Shane
  • 303
  • 2
  • 9
  • I opened the function app in app service editor with the direct URL: {functionAppName}.scm.azurewebsites.net/dev/wwwroot/ and then tried to create a subfolder for the other version of the DLL, but this is not picked up by the app. It only looks in the function folder. – Shane May 04 '18 at 07:39
  • It seems that you may need to use assembly binding redirect, you may need to leverage `AppDomain.CurrentDomain.AssemblyResolve` to solve your issue. Moreover, here are some similar issues, you could follow [azure-functions-binding-redirect](https://stackoverflow.com/questions/38093972/azure-functions-binding-redirect), [How to fix the assembly binding redirect problem in Azure Functions](https://codopia.wordpress.com/2017/07/21/how-to-fix-the-assembly-binding-redirect-problem-in-azure-functions/). – Bruce Chen May 04 '18 at 10:04
  • I resolve this by ensuring all project references pointed to packages dll's (from the packages subfolder) to eliminate potential version conflicts and then uploading all DLL's from the bin folder resolved it. – Shane May 07 '18 at 01:47
  • You could post your answer and summarize your solution for other community members who could encounter the similar issue. – Bruce Chen May 07 '18 at 01:51

2 Answers2

0

Do not try to upload global nuget packages manually. Instead refer this thread, How can I use NuGet packages in my Azure Functions? to import nuget libraries to your Azure function ecosystem.

After that, you can directly use those c# libraries as, for example

using Microsoft.SharePoint;
Ashokan Sivapragasam
  • 2,033
  • 2
  • 18
  • 39
  • Oddly, this didn't work; I included the full list of nuget packages, but received the warning about not able to find the assembly. Ultimately, ensuring all project references pointed to packages dll's to eliminate version conflicts and then uploading all DLL's from the bin folder resolved it. – Shane May 07 '18 at 01:46
  • @Shane; Glad, it worked. Looks like problem is typical to your case that you use multiple versions of the same library. – Ashokan Sivapragasam May 07 '18 at 05:07
0

Ensuring all project references pointed to packages folder (nuget) dll's to eliminate version conflicts and then uploading all DLL's from the bin folder resolved the issue in this case.

Shane
  • 303
  • 2
  • 9