Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
This repository was archived by the owner on May 1, 2024. It is now read-only.

[Bug] System.TypeLoadException thrown when Unit Testing AsyncCommand and AsyncValueCommand #964

@TheCodeTraveler

Description

@TheCodeTraveler

Description

When unit testing AsyncCommand and AsyncValueCommand using .NET Core on a non-windows operating system, System.TypeLoadException is thrown:

System.TypeLoadException : Could not load type 'System.Windows.Threading.Dispatcher' from assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

TypeLoadException is thrown for a combination of the following reasons:

  • BaseCommand.wpf.cs uses System.Windows.Threading.Dispatcher which is only available on Windows
  • .NET Core dependencies for the NuGet package assume the user is running WPF on Windows (see image)

image

Steps to Reproduce

  1. On macOS, Download/Clone reproduction sample: https://github.com/brminnick/AsyncCommandSample/releases/tag/System.TypeLoadException
  2. On macOS, in Visual Studio for Mac, open AsyncCommandSample.sln
  3. In Visual Studio for Mac, run all Unit Tests
  4. In Visual Studio for Mac, confirm the test failed

Screen Shot 2021-02-22 at 3 28 53 PM

Expected Behavior

Unit Test should pass

(The Unit Test does pass when the test is on a Windows machine)

Actual Behavior

System.TypeLoadException is thrown:

System.TypeLoadException : Could not load type 'System.Windows.Threading.Dispatcher' from assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Basic Information

  • Version with issue: v1.0.3
  • Last known good version: None

Workaround

Run unit tests on Windows

Reproduction Link

https://github.com/brminnick/AsyncCommandSample/releases/tag/System.TypeLoadException

Metadata

Metadata

Labels

bugSomething isn't working. Breaky break.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions