Skip to content

Latest commit

 

History

History
31 lines (20 loc) · 1.32 KB

File metadata and controls

31 lines (20 loc) · 1.32 KB

WindowsService-AI-Dependency-Failure

Illustrates dependency load exception when AI TelemetryClient.StartOperation method is called from a .NET 4.7.2 Windows Service.

Problem:

MS Visual Studio Intaller Project adds incorrect assemblies to the installer package.

Exception thrown when starting the installed windows service:

The type initializer for 'PerTypeValues1' threw an exception.

System.BadImageFormatException: Could not load file or assembly System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 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)

Discussion:

https://github.com/microsoft/ApplicationInsights-Home/issues/429

Solution:

Add the 4 following assemblies manually from project bin folder to the Application Folder in addition to default "Project Output" in installer project:

  1. System.Buffers
  2. System.Memory
  3. System.Numeric.Vectors
  4. System.Runtime.CompilerServices.Unsafe

Possibly Related:

dotnet/standard#250