Skip to content

System.TypeInitializationException: 'The type initializer for 'CommunityToolkit.Mvvm.Messaging.WeakReferenceMessenger' threw an exception.' #397

@DSBloom

Description

@DSBloom

Describe the bug

I upgraded my NuGet references from the old Microsoft.Toolkit.Mvvm to the new CommunityToolkit.Mvvm, and now my project will not run. It will build, but I cannot debug. I get the following error:
System.TypeInitializationException: 'The type initializer for 'CommunityToolkit.Mvvm.Messaging.WeakReferenceMessenger' threw an exception.

FileNotFoundException: Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

I noticed that 'System.Runtime.InteropServices.RuntimeInformation` was listed as a transitive package in the NuGet package manager UI, so I installed it as a Top-level package, but that did not help.

Regression

7.1.0

Steps to reproduce

I tried to reproduce this with a new WPF dotnet framework 4.8 project and I couldn't.

Expected behavior

I expect the application to launch.

Screenshots

image

IDE and version

VS 2022

IDE version

Microsoft Visual Studio Professional 2022 Version 17.3.1 VisualStudio.17.Release/17.3.1+32811.315 Microsoft .NET Framework Version 4.8.04084

Nuget packages

  • CommunityToolkit.Common
  • CommunityToolkit.Diagnostics
  • CommunityToolkit.HighPerformance
  • CommunityToolkit.Mvvm (aka MVVM Toolkit)

Nuget package version(s)

8.0.0

Additional context

No response

Help us help you

No, just wanted to report this

Metadata

Metadata

Assignees

No one assigned

    Labels

    external ⤴️Something related to or caused by an external projectmvvm-toolkit 🧰Issues/PRs for the MVVM Toolkit

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions