how to handle system.nullreferenceexception in c# windows service as I already written my code in try catch block.
I'm using S7 control & plc.cs for capturing data & inserting into database.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rajkiran SwainPosted Jun 7, 2017, 6:57 AM
NullRefException is one of the basic programming error you should learn and avoid. How did you set collectionDB? Or if it's not collectionDB was null, just share exception stacktrace here so i will see and help you point out the cause of this.
Besides, never catch the top-level Exception like this. Catching exception without logging is a bad practice in all cases.
Manas MohapatraPosted Jun 6, 2017, 1:38 AM