Open bh-sijtnic opened 1 month ago
@Nico-1987 I saw you were able to workaround the issue. Can you also try the WindowsSdkPackageVersion
for the latest Windows SDK projection update with the current known issues fixed to confirm whether it addresses your issue or not. If it doesn't, can you post a snippet of the generated code where the error happens in an issue that you open in the CsWinRT repo. If it does resolve it, this version will be the default in next month's .NET SDK servicing update at which point you can remove the WindowsSdkPackageVersion
property.
Thanks for the quick update, i just tested in our .NET 6 product with
<WindowsSdkPackageVersion>10.0.19041.52</WindowsSdkPackageVersion>
This did not fix the issue, actually the whole WinRT.SourceGenerator folder, and thus Generator.WinRTAotSourceGenerator\WinRTGlobalVtableLookup.g.cs does not exist (anymore?) in our obj path (for which we use a custom path)
<IntermediateFolder>$([MSBuild]::NormalizePath($(RootSourceFolder).int/))</IntermediateFolder>
Error: CSC : error CS8785: Generator 'WinRTAotSourceGenerator' failed to generate source. It will not contribute to t he output and compilation errors may occur as a result. Exception was of type 'IndexOutOfRangeException' with me ssage 'Index was outside the bounds of the array.'
I suffer from the same issue after .Net 8 SDK update to 8.0.403
25> Microsoft (R) Visual C# Compiler version 4.11.0-3.24376.4 (5e3a11e2)
25> Copyright (C) Microsoft Corporation. All rights reserved.
25> CSC : error CS8785: Generator 'WinRTAotSourceGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'IndexOutOfRangeException' with message 'Index was outside the bounds of the array.'.
25> System.IndexOutOfRangeException: Index was outside the bounds of the array.
25> at Generator.WinRTAotSourceGenerator.GetVtableAttributesToAddOnLookupTable(GeneratorSyntaxContext context, TypeMapper typeMapper, Func`3 isWinRTType, Func`2 isWinRTClass)
25> at Generator.WinRTAotSourceGenerator.GetVtableAttributesToAddOnLookupTable(GeneratorSyntaxContext context, TypeMapper typeMapper)
25> at Generator.WinRTAotSourceGenerator.<>c.<Initialize>b__0_17(ValueTuple`2 t, CancellationToken _)
25> at Microsoft.CodeAnalysis.TransformNode`2.<>c__DisplayClass6_0.<.ctor>b__0(TInput i, CancellationToken token)
25> at Microsoft.CodeAnalysis.TransformNode`2.UpdateStateTable(Builder builder, NodeStateTable`1 previousTable, CancellationToken cancellationToken)
25> -----
25> CompilerServer: server - server processed compilation - WordApp_d0yh1ael_wpftmp (net8.0-windows10.0.17763.0)
I tried all workarounds for this issue but nothing works
The only fix that works for me is:
dotnet-core-uninstall remove 8.0.403 --sdk
Have you tried the workaround to disable WinRT AOT optimizer in project file, that was proposed here?
<CsWinRTAotOptimizerEnabled>false</CsWinRTAotOptimizerEnabled>
At least for me it did work.
EDIT: Sorry, I just saw that you posted there that it didn't work for you.
@ekalchev please provide a binlog - we think the issue should be fixed but without further details we can't dig into what's going on in your system.
@baronfel is this enough or you need the entire log?
Unfortunately It's not enough to double check if you applied the workaround described above and/or see if there's some other context in your working environment that triggers the issue.
If you can create a developer community ticket to securly upload the binlog we can privately investigate if that's alright with you.
@baronfel Here the ticket https://developercommunity.visualstudio.com/t/Building-with-SDK-80403-throws-CSC-err/10779441 I attached two binlog files with and without
<CsWinRTAotOptimizerEnabled>false</CsWinRTAotOptimizerEnabled>
@manodasanW can you take a look at the binlogs and offer guidance?
I believe we have fixed this issue for our next update. But CsWinRTAotOptimizerEnabled
set to false should have workaround this issue at least with the version mentioned here of the Windows SDK projection. I will take a look at the binlogs to see why it didn't help.
Describe the bug
After updating the .NET 8 SDK from 8.0.304 to the latest 8.0.306 some or our projects targeting framework net8.0-windows10.0.19041 fail with error. We use Visual Studio 2022 17.10.7.
and
We did find that adding this to our Directory.Build.props code base "resolves" the issue, though in the documentation we can read its not recommended to use this property. For now we can keep this as a workarround, but we would like to understand the proper fix.
To Reproduce
I have not been able to reproduce this yet outside our own code base. We don't know where this code generator comes from and what it triggers.
Exceptions (if any)
and
Further technical details
.NET SDKs installed: 2.1.202 [C:\Program Files\dotnet\sdk] 2.1.512 [C:\Program Files\dotnet\sdk] 3.1.423 [C:\Program Files\dotnet\sdk] 5.0.416 [C:\Program Files\dotnet\sdk] 6.0.310 [C:\Program Files\dotnet\sdk] 6.0.427 [C:\Program Files\dotnet\sdk] 8.0.304 [C:\Program Files\dotnet\sdk] 8.0.306 [C:\Program Files\dotnet\sdk]
Visual Studio 2022 - 17.10.7
Windows 11 Version 23H2