Problems installing Application Insights on .NET 4.7.2 from Visual Studio

0

First of all I got all kinds of weird errors trying to use Visual Studio 15.9 Preview 1 including all kinds of popups during installation. I reverted back to Visual Studio 15.8 RTM but still received errors.

This is what I see trying to open my ASP.NET application.

[BadImageFormatException: Cannot load a reference assembly for execution.]

[BadImageFormatException: Could not load file or assembly 'System.Runtime' or one of its dependencies. Reference assemblies should not be loaded for execution.  They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +36
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +21
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

The DLL System.Runtime is showing as being the following

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\
  .NETFramework\v4.7.2\Facades\System.Runtime.dll
asp.net-mvc
azure-application-insights
asked on Stack Overflow Aug 24, 2018 by Simon_Weaver

1 Answer

0

Application Insights in Visual Studio are installed via a right click menu item.

First of all if you're doing any kind of 'magic' installation like this, first make sure your code is all checked into source control.

If it fails you can then see exactly what it tried to change. In my case it was the following. It had added these two :

enter image description here

  <dependentAssembly>
    <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Runtime.InteropServices" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
  </dependentAssembly>

When I commented them out the app worked again.

Be sure to check in Azure that data is coming through:

enter image description here

Wish I fully understood what happened though.

Note that after getting it working, the actual version of System.Runtime that is loaded is

C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.dll

answered on Stack Overflow Aug 24, 2018 by Simon_Weaver

User contributions licensed under CC BY-SA 3.0