Unable to build Blazor Server-side project after installing preview 8
Steps to reproduce the behavior:
Specified argument was out of the range of valid values. (Parameter 'index')
at Microsoft.AspNetCore.Razor.Language.Intermediate.IntermediateNodeCollection.get_Item(Int32 index)
at Microsoft.AspNetCore.Razor.Language.Components.ComponentReferenceCaptureLoweringPass.ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode)
at Microsoft.AspNetCore.Razor.Language.IntermediateNodePassBase.Execute(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode)
at Microsoft.AspNetCore.Razor.Language.DefaultRazorOptimizationPhase.ExecuteCore(RazorCodeDocument codeDocument)
at Microsoft.AspNetCore.Razor.Language.RazorEnginePhaseBase.Execute(RazorCodeDocument codeDocument)
at Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document)
at Microsoft.AspNetCore.Razor.Language.DefaultRazorProjectEngine.ProcessCore(RazorCodeDocument codeDocument)
at Microsoft.AspNetCore.Razor.Language.RazorProjectEngine.Process(RazorProjectItem projectItem)
at Microsoft.AspNetCore.Razor.Tools.GenerateCommand.<>c__DisplayClass46_0.<GenerateCode>b__0(Int32 i)
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0
1.1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica
1.ExecuteAction(Boolean& yieldedBeforeCompletion)Expected to see the successful build
If applicable, add screenshots to help explain your problem.
Add any other context about the problem here.
Include the output of dotnet --info
Can you show us your dotnet --info
please?
I had the same issue because the dotnet preview7 wasn't uninstalled automatically. After uninstalling it manually it worked. (Note: I also uninstalled the Blazor extension.)
I have the same problem.
My dotnet --info says:
.NET Core SDK (gem盲脽 "global.json"):
Version: 3.0.100-preview8-013656
Commit: 8bf06ffc8d
Laufzeitumgebung:
OS Name: Windows
OS Version: 10.0.17763
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview8-013656\
Host (useful for support):
Version: 3.0.0-preview8-28405-07
Commit: d01b2fb7bc
.NET Core SDKs installed:
2.1.800-preview-009677 [C:\Program Files\dotnet\sdk]
2.1.800-preview-009696 [C:\Program Files\dotnet\sdk]
2.1.800 [C:\Program Files\dotnet\sdk]
3.0.100-preview6-012264 [C:\Program Files\dotnet\sdk]
3.0.100-preview8-013656 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview7.19365.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview8.19405.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview7-27912-14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0-preview7-27912-14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
@sven5 Can you try if uninstalling the dotnet sdk 3.0.100-preview6-012264
helps?
I removed the 3.0.100-preview6-012264
folder manually and the old preview7 by uninstalling in programs and features. After that, I had to manually remove preview7 from C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App
However, I still get the error:
C:\Program Files\dotnet\sdk\3.0.100-preview8-013656\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(150,5): error : rzc generate exited with code 1.
Hmm are you using the latest Visual Studio version 16.3.0 Preview 2.0
? If not maybe updating helps.
Yes it should be the correct version
Microsoft Visual Studio Professional 2019 Preview
Version 16.3.0 Preview 2.0
VisualStudio.16.Preview/16.3.0-pre.2.0+29209.152
Microsoft .NET Framework
Version 4.7.03190
I have the same issue.
Use the latest VS Preview Version, only Preview 8 is installed and no Blazor extension installed)
Hmm sorry, then I am not quite sure how I fixed that issue last night. I also removed the .vs
and bin
/ obj
folders...
I had this problem, it was solved (in my case) by adding @ref:suppressField
My component inherits a base class, and I was doing something like this:
@if (!IsWaiting)
{
<Something @ref="field"/>
} else {
<Something @ref="field"/>
}
I added @ref:suppressField, and it worked.
What was painful about it was determining where the problem (in which file) it was occuring. There was no reference to the .razor file that was causing the problem. Had to remove everything and put each file back one by one.
@hitchhiker
I think you're right. We modified our usages of @ref fields and added @ref:suppressField
Now the project is compiling and working again.
Thank you for filing this issue. In order for us to investigate this issue please provide us the file which was causing this issue, so we can fix this.
Currently, I'm unable to reproduce this issue in a new and empty project.
I've found out that this issue deals with 3rd party components which are currently not upgraded to Preview 8. We're using DevExpress UI for Blazor components. By today, the DevExpress guys don't have upgraded their components.
When removing the components from the page the compilation is successful without error. The other solution as @hitchhiker already mentioned is to use the @ref:suppressField
.
That seems a little weird.
However, even if the project now compiles well it crashes at runtime because of changes in prev8.
So we'll have to wait until 3rd parties upgrade their products.
It would be helpful to know if other users facing this issue are also using 3rd party components.
Same thing here, I've been unable to reproduce it in an empty project.
Blazored.FluentValidation was the 3rd party package involved in my case.
Glad you found the cause for this. Looks like you'll have to wait till the updated dependencies will be available. Closing this issue as there is no action pending from our end.
@mkArtakMSFT - There is a bug here imho not sure where it belongs, i.e whether it's VS, or the razor tooling.
When this error occurs, the "Errors" pane of VS 2019 Community Preview 2, only shows the generic `error : rzc generate exited with code 2. " error - which doesn't help you at all with what went wrong or in which file.
If you run a dotnet build
from command line, you get more helpful output:
Build FAILED.
C:\Users\DarrellTunnell\source\repos\XYZ\src\ABC\ABC.Client\Pages\PlatformLogin.razor(3,5): warning RZ10014: Found markup element with unexpected name 'ABC.PlatformAdminLogin'. If this is intended to be a component, add a @using directive for its namespace. [C:\Users\DarrellTunnell\source\repos\XYZ\src\ABC\ABC.Client\ABC.Client.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview8-013656\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(150,5): error : rzc generate exited with code 2. [C:\Users\DarrellTunnell\source\repos\XYZ\src\ABC\ABC.Client\ABC.Client.csproj]
1 Warning(s)
1 Error(s)
Time Elapsed 00:00:01.89
@dazinator that should be already fixed in Preview9: https://github.com/aspnet/AspNetCore/issues/12661
i think this error produced by new update of preview 8 [Component Case Sensitive and putting @ before your Custom component before calling]
as i found in [Shared\MainLayout.razor] error on "LoginDisplay" it was "LogInDisplay"
and some components missed @ before
finally build success
This was closed, but I think that the solution is wrong. This is not just a 3rd party app not upgrading the @ref attributes. There seems to be a bug in the latest pre-release with regard to the @ref attributes themselves. I was able to reproduce this with a small amount of additional code added to a pure new Blazor project. See the Github code at
https://github.com/mikewodarczyk/BlazorVisualStudioBug
for a recreation of this issue.
@mikewodarczyk the issue you are referring to, with @ref attributes, is perhaps the one that is a known issue introduced in preview8? It's fixed again for preview9. It was announced here: https://devblogs.microsoft.com/aspnet/asp-net-core-and-blazor-updates-in-net-core-3-0-preview-8/
Remove backing field declarations when using @ref or specify the @ref:suppressField parameter to suppress automatic backing field generation.
It's a nasty one, I didn't realise they would announce a new preview with such a regression in, but.. I'll be going through the next preview announcement with a fine tooth comb before I upgrade again that's for sure :-)
Looks like this issue is closed, but an easy repro is to clone this sample "Simple quiz using Blazor.NET and Webassembly" project: https://github.com/Amine-Smahi/BlazorQuiz
Change the global.json file to reference RTM version of .NET Core:
"sdk": {
"version": "3.0.100"
}
For me this throws the "rzc generate exited with code 1" and I do not know why.
Looks like this issue is closed, but an easy repro is to clone this sample "Simple quiz using Blazor.NET and Webassembly" project: https://github.com/Amine-Smahi/BlazorQuiz
Change the global.json file to reference RTM version of .NET Core:
"sdk": {
"version": "3.0.100"
}For me this throws the "rzc generate exited with code 1" and I do not know why.
I am also getting the same error
Hi.
It looks like you are posting on a closed issue!
We're very likely to lose track of your bug/feedback/question unless you:
Most helpful comment
I had this problem, it was solved (in my case) by adding @ref:suppressField
My component inherits a base class, and I was doing something like this:
@if (!IsWaiting) { <Something @ref="field"/> } else { <Something @ref="field"/> }
I added @ref:suppressField, and it worked.
What was painful about it was determining where the problem (in which file) it was occuring. There was no reference to the .razor file that was causing the problem. Had to remove everything and put each file back one by one.