'Azure.Identity in PowerShell Cmdlet results in assembly exception (System.Runtime.CompilerServices.Unsafe)

I am trying to implement the Azure.Identity Library in a standard PowerShell module to retrieve a token. Both the library and the module are based on .netstandard 2.0.

The retrieval works in PowerShell 7 (.netcore) and VS Code Integrated Console (PS5.1) but not in a "native" PowerShell 5.1 console.

I am currently looking for the simplest possible way to resolve the conflict and redirect the dependencies. Does anyone have any good ideas about this?

Thanks a lot :)

Failure: Failure

StackTrace: StackTrace

FusionLog: Fusion Log (Binding)

Loaded Assemblys from my module in VS Code (CompilerServices + Text.Json) (Here, further assemblies are provided by VS Code PowerShellEditorServices.dll) Assemblys from my module

Loaded Assemblys from PowerShell 5: Assemblys from my module

Project Dependecies

Project Dependecies

Edit: Project Properties Project Settings



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source