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.

Blazor - Issue with auto-generated component code.

See original GitHub issue

Describe the bug

I have a component that wraps another component. I want an optional parameter in the first component. The render of the first component fails when the optional parameter is omitted. See #23892 for what I believe is the same issue.

To Reproduce

Component 1:

MbGrid (the component that I want to wrap) has a parameter of

[Parameter] public Func<TRowData, object>? SortExpressionSecond { get; set; } = null;

GCGrid (the wrapping component) has the parameter of

[Parameter] public Func<TRowData, object>? pSortExpressionSecond { get; set; } = null;

and a razor file of

<MBGrid SortExpressionSecond="pSortExpressionSecond" />

When I instantiate GCGrid as

<MBGrid />

the render of GCGrid fails with

Error: System.ArgumentException: Delegate to an instance method cannot have null 'this'.

Exceptions (if any)

Further technical details

C:\Solutions\OHI\Optimiser>dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.100-rc.2.20479.15
 Commit:    da7dfa8840

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19042
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.100-rc.2.20479.15\

Host (useful for support):
  Version: 5.0.0-rc.2.20475.5
  Commit:  c5a3f49c88

.NET SDKs installed:
  5.0.100-rc.2.20479.15 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-rc.2.20475.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-rc.2.20475.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0-rc.2.20475.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
captainsafiacommented, Nov 9, 2020

🤦‍♀️ Try now?

1reaction
simonzieglercommented, Nov 9, 2020

Hi @captainsafia I just took at look and #23892 seems still to be locked.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Blazor app won't compile due to auto-generated __Blazor ...
Describe the bug The auto-generated __Blazor namespaces can confuse the compiler and cause a failure to build.
Read more >
Scoped CSS is not auto-generated in Blazor after changing ...
So it appears that the static web assets are only generated in Development mode. I amended the CreateHostBuilder method in Program.cs ...
Read more >
Using Source Generators with Blazor components in .NET 6
In this post I describe a problem where upgrading my Blazor app to .NET 6 broke my source generators that relied on Blazor...
Read more >
Blazor, can't get embedded component to refresh
After, when I change one of these parameters, new data needs tobe loading from the backend web api and part of the problem...
Read more >
Handle errors in ASP.NET Core Blazor apps
This article describes how Blazor manages unhandled exceptions and how to develop apps that detect and handle errors.
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