flathub / flathub/com.visualstudio.code

C# Debugger for ASP.NET Project gives different results than using dotnet run

Ouverte
#698 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Shell
Étoiles
217
Forks
82
Merge moyen
1 j 7 h
PR mergées (30 j)
1

Description

Created several C# ASP.NET projects and tried using the C# and C# Dev Kit Extensions' Debugger. In most cases, it works as expected but additional issues keep piling up and could not find any solutions.

Eventually, I discovered that running `dotnet run` from the terminal resolved these issues, but could not find out why.

### PROBLEM - Using the C# VS Code Debugger vs `dotnet run` has different results

- Pages cannot be found by the Debugger unless using the RazorRuntimeCompilation NuGet package and adding it in program.cs
- Translations through .resx files are not applied when using the debugger.
- View overrides through scaffolding are not applied, and reverts to a default.

### ISSUE 1 - Loading .resx files

One MVC project uses .resx files for localization. Running this project with `dotnet run` has the page display in the correct languages.
When using the Debugger, it only shows English. In code, I've tried to print a list in the console of all keys, but it throws a MissingManifestResourceException when using the debugger, which seems to indicate that it cannot find the resx files.

### ISSUE 2 - View Override

A different MVC Project is set up with the Security template option to create local accounts. I've scaffolded the default Register page to also allow users to input additional information like First Name, Middle Name, Last Name, etc.

Using `dotnet run`, navigating to the page to Register shows the additional fields I've added.

Using the Debugger, it just shows the standard Register page without my changes. For some reason, the debugger does not find my changed files. First image is the page using the Debugger, second one is using `dotnet run`

Image

Image

### Things I've tried

- Ensured that launch.json and launchsettings.json match. They do.
- Toggle AddRazorRuntimeCompilation() in program.cs to see if it makes any difference. Without it, using the debugger doesn't work as it cannot find ANY file at all.
- Asked on Stack Overflow. No replies.

Most of my findings point towards the Flatpak being sandboxed and VS Code's Debugger being unable to find the correct files. But the debugger and dotnet commands have the same permissions so not sure why it could cause a difference.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

Reproduisez les différences signalées dans un projet ASP.NET à l’aide du débogueur de VS Code et de `dotnet run`. Commencez par comparer `launch.json` et `launchsettings.json`, puis examinez `Program.cs`, les ressources `.resx` et les vues Razor générées. Le travail est terminé lorsque vous avez identifié et documenté une cause reproductible des ressources manquantes et des remplacements de vues, ou confirmé que le comportement du débogueur et du terminal est équivalent.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
csharp, vscode
Domaine
backend, devtools
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Calme
Clarté
À clarifier
Accessibilité débutants
32/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.