NPa*_*utt 13 blazor blazor-client-side
我有一个带有第 5 版程序集的 Blazor WASM 项目,并尝试根据本文激活调试:https ://docs.microsoft.com/en-us/aspnet/core/blazor/debug?view=aspnetcore-3.1
为此,我确保更新了所有程序集引用并调整了启动设置。后者现在看起来像这样:
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:62310",
"sslPort": 44325
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"ApplySupportTool.Client": {
"commandName": "Project",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
这些也是我在 WASM 项目中的参考资料:
<PackageReference Include="System.Net.Http.Json" Version="3.2.0-preview5.20210.3" />
<PackageReference Include="Microsoft.AspNetCore.Components.DataAnnotations.Validation" Version="3.2.0-preview2.20160.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0-preview5.20216.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0-preview5.20216.8" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0-preview5.20216.8" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Runtime" Version="3.2.0-preview5.20216.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="3.2.0-preview5.20216.8" />
Run Code Online (Sandbox Code Playgroud)
为了测试,我从默认项目中复制了“计数器”页面。但是当我按 F5 调试IncrementCount方法中的断点时,它不会变成红色。我在一个新创建的默认项目中进行了测试,并且可以正常工作,因此我认为 Visual Studio Preview、Edge 和 .net core 具有正确的版本。
我注意到开发控制台中的这个警告只出现在我现有的项目中,而不出现在新创建的默认项目中:
DevTools 无法加载 SourceMap:无法加载 chrome-extension://ndcileolkflehcjpmjnfbnaibdcgglog/include.preload.js.map 的内容:HTTP 错误:状态代码 404,net::ERR_UNKNOWN_URL_SCHEME
我还需要添加或调整其他内容才能使其正常工作吗?在上面的文章中,就我所见,我找不到任何东西。
sw1*_*337 11
这是目前 Blazor 项目中的一个已知问题。调试器的启动速度比项目程序集慢/快,并且没有时间“查看”程序集。这是我的修复,直到他们解决这个问题。我在 Program.cs 中添加了一个延迟,以便在项目以调试模式启动时,它为调试器提供了正确附加的时间。我使用了 5000 毫秒,但如果你的机器比我的慢,你可能需要增加这个值。
public class Program
{
private static async Task DebugDelayAsync()
{
#if DEBUG
await Task.Delay(5000);
#endif
}
public static async Task Main(string[] args)
{
await DebugDelayAsync();
(...)
}
}
Run Code Online (Sandbox Code Playgroud)
小智 0
几天前,类似的事情也发生在我身上。
\n我采取的步骤如下:
\n| 归档时间: |
|
| 查看次数: |
2878 次 |
| 最近记录: |