Some variables do not exist in the current context in Rider Debugger mode
Asked Answered
T

1

9

I am trying to get the inspect the values of local variables. This feature works for some variables. For those that it doesn't, Rider brings up an error:

The name `variable_name` does not exists in the current context.

And image example of code and debugger watch error:

enter image description here enter image description here

This is decompiled code, but even here it works for some local variables. What could be the fix for this?

I already check Settings->Build, Execution, Deployment->Disable JIT optimization on module load (.NET/.NET Core only), but as it says, it only works for .NET/.NET Core modules

Tranquilize answered 26/10, 2019 at 21:45 Comment(6)
Could be that the assembly was compiled in Release and the variable was optimized away?Denmark
Not sure, I haven't compiled it my self. How can I check?Tranquilize
Open the assembly in JustCompile or ILSpy and look for the AssemblyConfiguration attribute at the assembly levelDenmark
Thank you! Indeed the assembly is marked as Release. I have access to the source code for the assembly in question, but it is maintained as a different project. I have compiled the source again in a Debug option. The tricky part is how to replace the .dll file. If I just got to explorer and replace it, I am getting an error that the The located assembly's manifest definition does not match the assembly reference.Tranquilize
It seems there are differences between Debug assembly and the Release assembly. My guess is either the assembly version or the Public Key Token. You can enable Fusion Log to see the reason the binding to the new assembly failed.Denmark
Same issue. My project was running in release mode.Keele
P
2

I had the same problem. In my case, the use of Fody was causing the problem, although the assembly was compiled in the Debug mode. After disabling Fody, I could see the variable value while debugging. I thought this might be useful for someone else. Please check if your project is using any IL manipulation tools, such as Fody.

Peccary answered 17/2, 2022 at 8:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.