After a recommendation from these answers, I’ve attempted to reference the ASP.NET 5 source code in order to debug the Antiforgery project.
I’ve put up a question on StackOverflow but it seems no one there knows the answer.
I have built the code successfully using the instructions in https://github.com/dotnet/aspnetcore/blob/master/docs/BuildFromSource.md using the Debug configuration.
I have added the source code project to my test project and referenced it.
I’ve checked that the Configuration is set to Debug.
I’ve made sure that “Suppress JIT Optimizations” has been checked.
“Optimize Code” in Project Properties -> Build, is unchecked for both projects.
“Debug Info” dropdown has been set to “Full” in the Advanced Options (Under Build tab) for both projects.
However when I hit the breakpoint in DefaultAntiforgeryTokenSerializer.Serialize()
, it gives me this error when viewing the method’s local vars in the Watch window:
How can I force the code to not be optimized?
I’m using Visual Studio Enterprise 2019 v16.8.3.
I would be pretty surprised if the problem came from the fact that an asset from a .Net library wasn’t made to be optimized.
Also, Asp.Net component you’re using has already been compiled, meaning changing the optimization settings of your project probably won’t change a thing.
I’d rather bet the problem is elsewhere in your code
When I built the ASP.NET 5 source code prior to referencing it, I put Debug as the build configuration.
When I need to drop down to any code from .net, short of managed code, I use https://github.com/dnSpy/dnSpy. It has proven itself invaluable many times. There’s tutorials for it online.
C# devs
null reference exceptions