简体   繁体   中英

Microsoft.ApplicationInsights missing

I am having problem with starting ASP.NET MVC5 application. Everything was working fine until now. While starting application I am getting below error:

Could not load file or assembly 'Microsoft.ApplicationInsights, Version=1.2.3.490, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 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.ApplicationInsights, Version=1.2.3.490, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

I have Microsoft.ApplicationInsights 1.2.3 installed. I also tried clean, rebuild, restart computer, restart computer and leave the room etc etc.

Does someone have any idea how to solve that problem?

Try reinstalling the package using NuGet package manager. Install an updated version if possible.

If you have a message like:

Could not load file or assembly '[Any-Package-Name], Version=[Any-Version]

This mean that you have issues with compatibility between different projects. In my case I had the nuget package Microsoft.ApplicationInsights with version 2.8.1 and one of the projects had 2.4. So I got RunTime Error, you need to have the same versions of the nuget packages that you are using in all your projects for not having this errors.

SOLUTION:

  • Right click on solution
  • Manage Nuget Packages for Solution
  • Search the package which you are having the issue
  • Click all the projects that are using the nuget package
  • Select the version for install/update in all of them
  • Click "Install"
  • Rebuild your Solution

I installed the new version with Install-Package Microsoft.ApplicationInsights -Version 2.10.0 and I got the same error.
I added this line into Web.config under <runtime><assemblyBinding ...> and it seems working for me, make sure to have Microsoft.ApplicationInsights.dll file in the bin folder as well. Good luck.

<dependentAssembly>
  <assemblyIdentity name="Microsoft.ApplicationInsights" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
  <bindingRedirect oldVersion="0.0.0.0-2.10.0.0" newVersion="2.10.0.0"/>
</dependentAssembly>

Install the Nugget package Microsoft.ApplicationInsights.NLogTarget to enable nlog recognize Application insight and reference it.

I had this same problem with a project I worked on with.Net Core 3.1 After I installed the Nugget package it was fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM