microsoft / CsWinRT

C# language projection for the Windows Runtime
MIT License
536 stars 102 forks source link

System.NotSupportedException when PublishAot is set to true #1623

Closed hez2010 closed 3 weeks ago

hez2010 commented 3 months ago

Describe the bug The below exception occurred in TypeNameSupport.ResolveGenericType when PublishAot is set to true but not running under NativeAOT.

System.NotSupportedException: 'Cannot provide generic type from 'Windows.Foundation.IAsyncOperation`1'.'

To Reproduce

  1. Checkout the aot branch of https://github.com/hez2010/WinRTServer/tree/aot
  2. Run the project directly in VS

Expected behavior No exception.

Version Info Package built from staging/AOT branch.

Additional context

RuntimeFeature.IsDynamicCodeCompiled will be set to true if PublishAot is set to true in csproj, regardless of whether the executable is published with NativeAOT or not.

manodasanW commented 3 months ago

I assume this is a first chance exception that is caught that you are seeing and that things still work or does it also crash?

hez2010 commented 3 months ago

You are right. It's a first chance exception. It doesn't crash.

manodasanW commented 3 months ago

Yea that is known, I will keep this open to track this until I decide if I want to leave it as is or put in some logic to handle that which in theory isn't really needed as we got type information later on which we use.

Gaoyifei1011 commented 2 months ago

Yea that is known, I will keep this open to track this until I decide if I want to leave it as is or put in some logic to handle that which in theory isn't really needed as we got type information later on which we use.

I've seen this happen with a few methods as well e8a8632a93f879de2270268f96a97b75