'Null Reference Exception.....but the value is NOT NULL
I have a line of code string managerFirstName = "[email protected]"; that is flagging as NULL. How is this NULL....its a string that is populated when its created....is there an error with my VS2013? or a setting I need to change?

Solution 1:[1]
It's not the highlighted line that is crashing - the IDE is highlighting the wrong line.
The stack trace you posted mentions RFS.DotNetNuke.Service.ActiveDirectorySynchronise.something. Try and look for a line of code that uses that object - probably the line of code above the highlighted line (GetManagerForOrgUnit). Examine each of the parameters for that call and see if you can find a null reference.
Solution 2:[2]
If the problem is code related, not build, this looks like a threading issue. Try wrapping the whole function in a lock, and looking for how contexts could be getting mangled.
Solution 3:[3]
Try after removing Visual Studio component cache.
Close Visual Studio (ensure devenv.exe is not present in the Task Manager) Delete the directory:
%USERPROFILE%\AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCacheRestart Visual Studio
Solution 4:[4]
This used to happen to me in VS2k13 a lot. Basically your code is not getting rebuilt. Even after a clean/rebuild, some code refuses to compile. What used to work for me was1. Clean/rebuild. 2. Make a code change in the area of code you are looking at. 3. Put a breakpoint in the calling method. 4. Debug and f11 step line by line to your code change.
Solution 5:[5]
Would just like to say thank you to everyone who helped me out with this Q....I found the cause...just above the
ADUser managerUser = GetManagerNameForOrgUnit(coreData.OrgAssignment_0001.OrgUnit.ID, coreData.PersonnelNo);
there is an if statement, which during testing always stops the code from hitting GetManagerNameForOrgUnit(), I have been manually stepping over this if.
I commented it out and the code works fine.
Thanks again
Solution 6:[6]
I faced this problem when I was manually skipping execution of few lines (apparently unrelated code section).
Solution 7:[7]
I have had this issue with VS 2022. Where this happens I get null reference and errors. I have found that this was because my debug configuration was set to Release and not debug.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | SSS |
| Solution 2 | Sentinel |
| Solution 3 | marc_s |
| Solution 4 | Sentinel |
| Solution 5 | John |
| Solution 6 | Zubaer Naseem |
| Solution 7 | Jack |

