question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Installing 3.0 Preview 3 SDK broke build for 3.0 Preview 2 Razor Components app

See original GitHub issue

I created an app with the Preview 2 SDK (released bits). Today I installed the latest available Preview 3 bits (https://dotnetcli.blob.core.windows.net/dotnet/Sdk/release/3.0.1xx/dotnet-sdk-latest-win-x64.exe) and now I get build errors for the Razor Components cshtml files. I’m not sure if this is expected, since there have been a lot of changes in this area between Preview 2 and Preview 3.

Installation reported these bits, for context:

The following were installed at: ‘C:\Program Files\dotnet’ • .NET Core SDK 3.0.100-preview3-010343 • .NET Core Runtime 3.0.0-preview3-27421-7 • ASP.NET Core Runtime 3.0.0-preview3-19121-17 • .NET Core Windows Desktop Runtime 3.0.0-preview3-27420-40

The build errors I get are like this one (note, it’s in a generated file for the .cshtml):

obj\Debug\netstandard2.0\Razor\Pages\Counter.cshtml.g.cs(35,48): error CS0234: The type or namespace name ‘EventCallback’ does not exist in the namespace ‘Microsoft.AspNetCore.Components’ (are you missing an assembly reference?) [D:\src\AppBuilding\src\OrderSite.App\OrderSite.App.csproj]

The generated line of code is:

builder.AddAttribute(7, "onclick", Microsoft.AspNetCore.Components.EventCallback.Factory.Create<Microsoft.AspNetCore.Components.UIMouseEventArgs>(this, IncrementCount));

With the Preview 2 SDK, the generated line of code was:

builder.AddAttribute(7, "onclick", Microsoft.AspNetCore.Components.BindMethods.GetEventHandlerValue<Microsoft.AspNetCore.Components.UIMouseEventArgs>(IncrementCount));

Note: if I create a new Razor Components project with the Preview 3 SDK installed, it builds fine. The project created is very different from the Preview 2 template however.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rynowakcommented, Feb 22, 2019

This is expected for now.

We’re still working on the compiler and there will be changes between releases. We don’t expect the runtime from preview2 to be compatible with a nightly build of the SDK.

0reactions
mitsuakiwatanabecommented, Aug 15, 2019

@DefenceAquireSustain I had the same problem. but I read this news and solved it.

Remove use of namespace Microsoft.AspNetCore.Components.Layouts.

In Razor components rename OnInit to OnInitialized and OnInitAsync to OnInitializedAsync.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ASP.NET Core updates in .NET Core 3.0 Preview 2
Razor Components are a new way to build interactive client-side web UI with ASP.NET Core. This release of .NET Core 3.0 Preview 2...
Read more >
ASP.NET Core updates in .NET Core 3.0 Preview 3
You can now add Razor Components to Razor Class Libraries and reference them from ASP.NET Core projects using Razor Components. To create ......
Read more >
Component libraries are broken in 3.0.0 Preview 2 #7127
Install the SDK 3.0.0 Preview 2; Install VS 2019 Preview 2; Run the commands dotnet new -i Microsoft.AspNetCore.Blazor.Templates
Read more >
3.0.0-preview2 Milestone
NET framework for building modern cloud-based web applications on Windows, Mac, or Linux. - 3.0.0-preview2 Milestone · dotnet/aspnetcore.
Read more >
Experimental Razor Editor - VS 16.9.0 Preview 3.0
After enabling experimental razor editor on VS 2019 Preview 3, the editor keeps complaining: CS0246 when inheriting classes in components (class is in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found