4
votes

I am receiving the following error after publishing to Azure App Service.

Could not load file or assembly 'Microsoft.ApplicationInsights, Version=1.2.0.5639, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

In the WebAPI project I clearly see the Microsoft.ApplicationInsights reference and the version number is "1.2.0.5639".

I am using VSO as my build server (vNext not XAML-based). I noticed in the VSO build logs that I was receiving a warning that the DLL was missing as well.

C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1819,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.ApplicationInsights, Version=1.2.0.5639, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

The build server also clearly shows this:

Primary reference "Microsoft.ApplicationInsights, Version=1.2.0.5639, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL".

With the following warning:

[warning]C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1819,5):

Warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.ApplicationInsights, Version=1.2.0.5639, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

The only thing I can think of right now is maybe the processor architecture being MSIL is the problem?

UPDATE: I am also publishing 3 web jobs (each that user Application Insights in their own right). Currently I am including the webjobs in the 'webjobs-list.json' file but I'm removing it to hopefully isolate the issue. It appears that 2 / 3 webjobs are able to find the DLL and are copying it to their

UPDATE 2: Removing the WebJobs from the JSON file didn't help.

UPDATE 3: OK, so I managed to get it working. BUT, only when I deploy from Visual Studio IDE, not through my automated build on VSO. :*( I used the Visual Studio context menu by right clicking on the WebAPI project then finding Application Insights menu item and using the 'add application insights wizard'. This is strange because App Insights has been working for quite some time in this project. But after I linked it to my existing app insights instance it added a few entries into web.config. Build / deploy got the WebAPI to start working again. I even added back in the WebJobs to the JSON file.

3
I am having the same problem, did you find any solution for the build server?Jorge Fioranelli
I am having this issue as well. The logs from the NuGet Installer step of my build definition suggest that the packages are being put into the correct folder, but when the Visual Studio Build step tries to resolve references to the DLLs it complains that they don't exist.Adam Goodwin

3 Answers

0
votes

Make sure on the properties view for the DLL that Copy Local is set to "True"

0
votes

Another guess - may it be the issue with the path to packages folder? May it differ on VSO build comparing to your local installation? Make sure you define SolutionDir variable if it is used for referencing packages folder

0
votes

In my case, when I added Application Insights to my project through the Solution Explorer context menu in Visual Studio, all of the NuGet packages were (somehow) not added correctly.

My solution would build locally, but would fail as described in this question when built using Visual Studio Team Services. After deleting my local workspace, then downloading everything from VSTS again, attempting to build my solution locally would fail in the same way that it did online.

What I found was that although I originally had all of the required NuGet packages on my computer, clicking the "Add Application Insights Telemetry..." context menu item did not update my packages.config file correctly.

So on the build server, and after cleaning out my workspace folder, NuGet wouldn't restore all of the required packages because they weren't all listed in the packages.config file.

The missing packages were:

<package id="Microsoft.ApplicationInsights" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.ApplicationInsights.Agent.Intercept" version="1.2.1" targetFramework="net45" />

My solution was to roll back my changeset that added Application Insights, in case anything else was broken that I didn't know about, then use the context menu option to add it back again. The second time around it seemed to work correctly.