c# - 在 Visual Studio 2019 中调试 Blazor WebAssembly 代码隐藏文件时无法检查组件属性
问题描述
我最近将我的 Blazor Server 应用程序转换为 Blazor WebAssembly,并注意到 Visual Studio 2019 中的调试不再正常工作。
我仍然可以单步调试我的组件并检查局部变量,但我无法再以任何方式检查我的组件的属性。Visual Studio 告诉我“无法评估”。
我的代码是使用代码隐藏方法构建的。我发现如果我将代码文件直接合并到组件中的 @code 块中,那么问题就会消失。但我不想这样做,因为这似乎是倒退了一步。
示例 1. 直接嵌入到组件中的代码...检查属性工作正常
反剃刀
@page "/Counter"
<DebugChild Max="20"></DebugChild>
DebugChild.razor
<h2>DebugChild</h2>
@code
{
[Parameter]
public int Max { get; set; }
protected override void OnInitialized()
{
var x = Max; //I can inspect Max here
}
}
示例 2. 代码拆分为代码隐藏文件...检查属性不起作用
反剃刀
@page "/Counter"
<DebugChild Max="20"></DebugChild>
DebugChild.razor
@inherits BlazorWASMHosted.Client.Components.DebugChild
<h2>DebugChild</h2>
DebugChild.razor.cs
Using Microsoft.AspNetCore.Components;
namespace BlazorWASMHosted.Client.Components
{
public class DebugChild : ComponentBase
{
[Parameter]
public int Max { get; set; }
protected override void OnInitialized()
{
var x = Max; //I CANNOT inspect Max here
}
}
}
我尝试使用部分类而不是 interitance 进行代码隐藏,但也没有运气。有没有人有什么建议?
解决方案
推荐阅读
- r - 如何将数据从 R 数据框中的第 i 行第 2 列更新到第 j 列第 1 行?
- go - 如何使用 redisgo Api 设置带有 Expiry 的密钥
- html - 页面适用于桌面,但页眉在移动设备上被截断
- sql - SQL SERVER - GROUP BY 条件(当数据不存在时)
- regex - 使用正则表达式从 Twitter 数据中提取“提及”的问题
- reactjs - 页面内容未显示在源代码中
- javascript - 为什么我的 onclick 属性在提交时不运行该功能?
- linux - 理解 ./ 在终端
- node.js - ISO 日如何在猫鼬中工作?
- javascript - Firefox 的 javascript 扩展 - querySelectorAll 和类名无法正常协同工作