Description
Description
Description:
When running 3rd party application with the latest .NET 9 build, applications cannot launch, or some functions don't work anymore. After investigating, we found the issue is caused by Windows sdk, which is thrown "Non-blittable generic types cannot be marshaled" exception.
Application Name: NatTypeTester, MyMoneyNet, FlowLauncher, ModernFlyouts, TextGrab, lively,CountdownNumberPuzzleSolver
OS: Windows 10 21H2
CPU: X64
.NET Build Number: dotnet-sdk-9.0.100-preview.3.24123.6
App & Source Location checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1977811
Github Link:
https://github.com/HMBSbige/NatTypeTester
https://github.com/MoneyTools/MyMoney.Net
https://github.com/Flow-Launcher/Flow.Launcher
Reproduction Steps
Minimal Repro steps (Demo attached):MarshalDirectiveExceptionDemo.zip
The machine has dotnet-sdk-9.0.100-preview.3.24123.6 installed.
1.Create a new Console project.
2.Update TargetFramework in .csproject to "net9.0-windows10.0.22621.0", which is look like this:
<TargetFramework>net9.0-windows10.0.22621.0</TargetFramework>
3.Add following code into Program.cs file:
using Windows.Globalization;
using Windows.Media.Ocr;
List<Language> possibleOCRLanguages = OcrEngine.AvailableRecognizerLanguages.ToList();
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
- Launch the app.
Expected Result:
Expected behavior
App launch successfully.
Actual behavior
Actual Result:
Launch failed with error:
System.Runtime.InteropServices.MarshalDirectiveException
HResult=0x80131535
Message=Non-blittable generic types cannot be marshaled.
Source=WinRT.Runtime
StackTrace:
at ABI.System.Collections.Generic.IEnumerator`1.get_HasCurrent()
at ABI.System.Collections.Generic.IEnumerator`1.FromAbiHelper.MoveNext()
at ABI.System.Collections.Generic.IEnumerator`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Program.<Main>$(String[] args) in E:\Demos\MarshalDirectiveExceptionDemo\MarshalDirectiveExceptionDemo\Program.cs:line 4
Regression?
Yes
Verify Scenarios:
1). Windows 10 21H2 AMD64 + dotnet-sdk-8.0.101: Pass
2). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-preview.2.24119.3: Pass
3). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-preview.3.24123.6: Fail
4). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-preview.3.24126.3: Fail
Known Workarounds
No response
Configuration
Dotnet Info:
.NET SDK:
Version: 9.0.100-preview.3.24123.6
Commit: 884fddb17a
Workload version: 9.0.100-manifests.06e7bcac
MSBuild version: 17.10.0-preview-24122-01+d4cb14fe4
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.100-preview.3.24123.6\
.NET workloads installed:
[wasm-tools]
Installation Source: VS 17.8.34601.278
Manifest Version: 9.0.0-preview.2.24123.1/9.0.100-preview.2
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100-preview.2\microsoft.net.workload.mono.toolchain.current\9.0.0-preview.2.24123.1\WorkloadManifest.json
Install Type: Msi
Host:
Version: 9.0.0-preview.2.24123.1
Architecture: x64
Commit: 99b7601
.NET SDKs installed:
9.0.100-preview.3.24123.6 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 9.0.0-preview.2.24121.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 9.0.0-preview.2.24123.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 9.0.0-preview.2.24122.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other information
@dotnet-actwx-bot @dotnet/compat