I have been getting an unexpected System.NullReferenceException
when filling HTML form attributes in a view using a for loop.
At the time of the error the program breaks and shows this prompt:
When I check the exception when thrown from Microsoft.AspNetCore.Mvc.ViewFeatures.dll
checkbox the program stops throwing this error. However when I restart Visual Studio 2022 the box gets unchecked and I have to check it manually all over again.
How could I make it remain checked ?
I am working with ASP.NET Core 7 MVC.
Problem fixed in: Visual Studio 2022 version 17.8.x
After checking out Qiang Fu's answer, I stumbled upon the solution. In Microsoft's Developer Community the user David Funk reports the same bug :
when I add conditions to an exception this is only persistent for the current Visual Studio instance. I.e. after restarting Visual Studio the exceptions are gone again.
The feedback bot informs him that the issue has been solved in the last version released (version 17.8.x).
So in order to solve this issue you just need to update Visual Studio 2022 to version 17.8.x or above, for me it worked just fine as I was working in version 17.4.x.