C# / Visual Studio - Object is null unless I have a Breakpoint
I'm specifically using the Google Contacts API at the moment, but this could be true of other scinarios as well.
I have the following code:
Contact newContact = new Contact();
When I let the code run without any breakpoints, I get a NullReferenceExc开发者_开发问答eption on all of the properties of this object. However, if I put a breakpoint just after this line, I can see all of the properties have been initialises and the rest of my code executes fine.
Any idea's would be greatly appreciated
Maybe it takes a while to initialize Contact
object (i.e. download data from internet). If it is done asynchronous then when you set a breakpoint you give program a time to do it.
精彩评论