1

I am suddenly seeing this error when running my app (published on Azure app service:

Could not load file or assembly 'Microsoft.SharePoint.Client, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified. at SharePointLibrary.SPClient.GetAllUsers() at ADVWKSP.Managers.UserManager.GetUsers() in C:\Users\bassie\source\repos\TFS\ADVWKSP\ADVWKSP\Managers\UserManager.cs:line 21

It runs fine on my machine, and it used to run fine after publish but now it just suddenly starts crying about this file missing.

I checked in Kudu and I can only see the SharePoint.Client.Runtime:

enter image description here

Why? How can I ensure that all required libraries are published with the project. Why did this suddenly stop working?

Nancy
  • 26,865
  • 3
  • 18
  • 34
Bassie
  • 9,529
  • 8
  • 68
  • 159

3 Answers3

1

The hosting environment of azure web app contains a standard installation of .Net framework 2.0 to .Net framework 4.5.

If your application referenced assemblies which is not build in .Net framework, you have to "include" them with your deploy package. Even these are Microsoft assemblies.

Setting the Copy Local property to True for the referenced assembly may fix it.

1.In Solution Explorer find your project's reference to the library.

2.Right click and choose Properties.

3.In the Properties window set Copy Local to True.

As you said, it works locally on IIS Express, please try to deploy your website content manually to Azure via KUDU or FTP client and find out whether it works or not.

Joey Cai
  • 18,968
  • 1
  • 20
  • 30
0

Adding the following parameter

/deployonbuild=false

to the msbuild command line fixed the issue.

Giles Roberts
  • 6,407
  • 6
  • 48
  • 63
  • 1
    Hi, could you add some context to your answer, please? Perhaps the steps to accomplish this. – Connor Low Jun 29 '21 at 23:42
  • 1
    @ConnorLow Oh this is a long time ago now. Let's see if I can remember. When deploying the project I used msbuild in the deployment pipeline. It gave the above error. When I added the parameter /deployonbuild=false to msbuild command line the error went away and the project worked correctly. – Giles Roberts Jul 03 '21 at 15:04
0

I faced the similar kind of issue when my app service function version was 3, but function source was targeted function version 4. updating the app service sorted the issue

Heshan
  • 772
  • 8
  • 22