Could not load file or assembly ‘Microsoft.AI.Web’ or one of its dependencies. The system cannot find the file specified.

Recently I was creating an Asp.Net web application for a SharePoint POC where we wanted to display SharePoint list data using CSOM (Client side object model using C#.Net), but I got an error as: Could not load file or assembly ‘Microsoft.AI.Web’ or one of its dependencies. The system cannot find the file specified.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileNotFoundException: Could not load file or assembly ‘Microsoft.AI.Web’ or one of its dependencies. The system cannot find the file specified.

And the full error looks like below:

Could not load file or assembly ‘Microsoft.AI.Web’ or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly ‘Microsoft.AI.Web’ or one of its dependencies. The system cannot find the file specified.

Could not load file or assembly ‘Microsoft.AI.Web’ or one of its dependencies. The system cannot find the file specified.

Just to give a background, I was creating an asp.net application and add the Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.client.Runtime.dll from NuGet packages.

To resolve this you can add “Microsoft.ApplicationInsights.Web” dll from NuGet.

To do so, Right click on References inside Solution Explorer and click on “Manage NuGet Packages” like below:

microsoft.ai.web nuget package
microsoft.ai.web nuget package

And then you can search for “Microsoft.ApplicationInsights.Web” and then click on Install.

But in my case, the dll was already added. So I just need to update the dll. In the same NuGet manager,

Click on the Updates tab and select “Microsft.ApplicationInsights.Web” and then click on Update. This will update to the latest version.

Could not load file or assembly Microsoft.AI.Web or one of its dependencies
Could not load file or assembly Microsoft.AI.Web or one of its dependencies

Now the error “Could not load file or assembly ‘Microsoft.AI.Web’ or one of its dependencies. The system cannot find the file specified.” will not come.

Install Microsoft.ApplicationInsights.Web from NuGet Package Manager Console

There is another approach we can install Microsoft.ApplicationInsights.Web from NuGet Package Manager Console.

From Visual Studio 2017 click on Tools -> NuGet package manager -> Package Manager Console.

Install Microsoft.ApplicationInsights.Web from NuGet Package Manager Console
Install Microsoft.ApplicationInsights.Web from NuGet Package Manager Console

Then in the console write the below command,

Install-Package Microsoft.ApplicationInsights.Web

and to install into a particular project then run the below command.

Install-Package Microsoft.ApplicationInsights.Web <ProjectName>

Install Microsoft.ApplicationInsights.Web from NuGet Package Manager Console
Install Microsoft.ApplicationInsights.Web from NuGet Package Manager Console

Once you click on Enter after writing the above command, it will install Microsoft.ApplicationInsights.Web and you will not get the error.

Update Microsoft.ApplicationInsights.Web from NuGet Package Manager Console

If you have already installed Microsoft.ApplicationInsights.Web and still you are getting the above error? Then you can update Microsoft.ApplicationInsights.Web from NuGet Package Manager Console.

Right click on Reference folder and then click on “Manage NuGet Packages…“, then you can search for “Microsoft.ApplicationInsights.Web” and there you can click on Update to the latest version like below:

Could not load file or assembly ‘Microsoft.AI.Web’ or one of its dependencies
update Microsoft.ApplicationInsights.Web

The error can come in WCF services or windows applications or web applications. Every time you need to install Microsoft.ApplicationInsights.Web from NuGet Package Manager.

You can also check an error which comes in an asp.net application.

You may like following NuGet SharePoint PnP CSOM tutorials:

I hope this tutorial will help to resolve the Could not load file or assembly ‘Microsoft.AI.Web or one of its dependencies. The system cannot find the file specified error.

>