Error with NuGet Package in Windows Compatibilty Mode Which Works in Debug Mode

Today I tried to use the following test library inside UiPath Studio 22.4.3:

//-Begin----------------------------------------------------------------

using System;
using System.Runtime.InteropServices;

namespace LibraryTest {

  public class LibraryTestLib {

    //-Message----------------------------------------------------------
    public string Message() {
      return "Hello World from LibraryTest.LibraryTestLib Message";
    }

  }

}

//-End------------------------------------------------------------------

I compiled this library with the target frameworks net6.0-windows7.0 and net461 and tested it successfully with PowerShell 5 (Windows - Legacy) and 7 (Windows).

#-Begin-----------------------------------------------------------------

If([System.Environment]::Version.Major -le 4) {
  #-net461--------------------------------------------------------------
  Add-Type -Path "$($PSScriptRoot)\net461\LibraryTest.dll"
} ElseIf([System.Environment]::Version.Major -gt 4) {
  #-net6.0-windows7.0---------------------------------------------------
  Add-Type -Path "$($PSScriptRoot)\net6.0-windows7.0\LibraryTest.dll"
}

[LibraryTest.LibraryTestLib]$LibTest = [LibraryTest.LibraryTestLib]::new();
$LibTest.Message();

#-End-------------------------------------------------------------------

In my last step I built a test NuGet package to use this test library inside UiPath.

LibraryTest.1.0.0.nupkg (5.2 KB)

This library worked with UiPath as expected in Windows - Legacy compatibility mode.

LibraryTestWindowsLegacy.xaml (3.9 KB)

Also this library worked with UiPath as expected in Windows compatibility mode with debugging.

But this library do not worked with UiPath in Windows compatibility mode at runtime.

image

LibraryTestWindows.xaml (4.3 KB)

I got the error CS0246 of a missing directive or reference. But I imported my library.

image

Am I doing something wrong or is this a bug in UiPath Studio when compiling in Windows compatibility mode?

Thanks for hints, tips and solutions.