2

I have a c# model with a DateTime property LastActivityDate, and I am trying to change it date to something else (some back date) while debugging from Quick Watch window (also tried immediate window). But when I do so, I got crash

Object reference not set to an instance of an object

Error Description enter image description here

It works if I do following:

processingDates.LastActivityDate = DateTime.Now

But doesn't work with following:

processingDates.LastActivityDate = new DateTime(2016,6,12)

Could not get the reason for this even after scratching my head for some hours.

Does anyone has a clue?

Note: The class is public, and the property is not readonly (also public). Just a simple get;set; property

Edit (adding code to remove confusion that processingDates might be null):

(I don't want to change code, so while debugging I am changing value just after instantiating)

var processingDates = new MyClassParameter()
{
    StopRecurrenceProcessDate = DateTime.Now,
    NextProcessingDate = DateTime.Now,
    LastActivityDate = DateTime.Now
};

if (projectId <= 0) //I AM Changing value in quick watch here
SSD
  • 1,373
  • 2
  • 13
  • 20
  • it sounds like `processingDates` is null; without context, I can't see how we can really comment much here... – Marc Gravell Apr 20 '18 at 12:14
  • Thats the first impression of error @MarcGravell. But as mentioned in the question, the other code works on same model, and in same Watch/Immediate window – SSD Apr 20 '18 at 12:15
  • You have some other problem here than since you get the error because `processingDates` is null. You would have first to instantiate `processingDates` in immediate window and than modify the `LastActivityDate` – Nikola.Lukovic Apr 20 '18 at 12:18
  • @Nikola.Lukovic if processing date was null, the other code mentioned in the question will also not work in same Watch window. Also it is not null as I see while debugging – SSD Apr 20 '18 at 12:20
  • Edited question, added some code. @Nikola.Lukovic. – SSD Apr 20 '18 at 12:26
  • Am I only in the world to get this problem? :) – SSD Jul 27 '18 at 08:57
  • I believe this is the solution you're looking for? https://stackoverflow.com/questions/46182977/how-to-edit-a-datetime-variable-during-visual-studio-2013-debug-session/46183277 – Guest Jul 24 '20 at 17:00

0 Answers0