CsWinRT icon indicating copy to clipboard operation
CsWinRT copied to clipboard

System.NotSupportedException when PublishAot is set to true

Open hez2010 opened this issue 1 year ago • 4 comments

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.

hez2010 avatar May 19 '24 04:05 hez2010

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?

manodasanW avatar May 19 '24 18:05 manodasanW

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

hez2010 avatar May 20 '24 01:05 hez2010

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.

manodasanW avatar May 21 '24 01:05 manodasanW

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

Gaoyifei1011 avatar Jun 21 '24 01:06 Gaoyifei1011