Sitelet https://github.com/coverlet-coverage/coverlet/issues/1818
Skip to content

[BUG] TypeInitializationException when targeting .NET Framework #1818

Description

@martincostello

Describe the bug

When targeting net481 with coverlet.msbuild@8.0.0, a TypeInitializationException is thrown when tests are run.

To Reproduce

  1. Clone martincostello/sqllocaldb@369c323 on a Windows machine
  2. Run build.ps1 from the root of the repository.

Expected behavior

Tests pass and coverage is collected.

Actual behavior

Error: System.TypeInitializationException : The type initializer for 'Coverlet.Core.Instrumentation.Tracker.MartinCostello.SqlLocalDb_d1a4020d-c271-494f-94d5-55a151367e7c' threw an exception.
---- System.IO.FileNotFoundException : Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

  Failed MartinCostello.SqlLocalDb.Interop.WindowsRegistryTests.OpenSubKey_Returns_Null_If_Key_Not_Found [152 ms]
  Error Message:
   System.TypeInitializationException : The type initializer for 'Coverlet.Core.Instrumentation.Tracker.MartinCostello.SqlLocalDb_d1a4020d-c271-494f-94d5-55a151367e7c' threw an exception.
---- System.IO.FileNotFoundException : Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
  Stack Trace:
     at Coverlet.Core.Instrumentation.Tracker.MartinCostello.SqlLocalDb_d1a4020d-c271-494f-94d5-55a151367e7c.RecordHit(Int32 )
   at MartinCostello.SqlLocalDb.Interop.WindowsRegistry.OpenSubKey(String keyName) in /_/src/SqlLocalDb/Interop/WindowsRegistry.cs:line 18
   at MartinCostello.SqlLocalDb.Interop.WindowsRegistryTests.OpenSubKey_Returns_Null_If_Key_Not_Found() in /_/tests/SqlLocalDb.Tests/Interop/WindowsRegistryTests.cs:line 18
----- Inner Stack Trace -----
   at Coverlet.Core.Instrumentation.Tracker.MartinCostello.SqlLocalDb_d1a4020d-c271-494f-94d5-55a151367e7c..cctor()

Configuration (please complete the following information):

Please provide more information on your .NET configuration:

  • Which coverlet package (collector, console, msbuild, ...) and version was used? coverlet.msbuild@8.0.0
  • Which version of .NET is the code running on? net481
  • What OS and version, and what distro if applicable? Windows 10
  • What is the architecture (x64, x86, ARM, ARM64)? x64
  • Do you know whether it is specific to that configuration? Yes

Additional context

None.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    SolvedThe issue is solved and can be closedbugSomething isn't workingdocumentationskip-changelogignore PR for change.log document (release-drafter

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions