locked
Null Reference Exception in EventReceiver RRS feed

  • Question

  • Hi All,

          I have written a even receiver like the following..

     


    Prasad Kommuru


    Friday, July 26, 2013 5:49 AM

Answers

  • Hello,

    Try to TryParse() or ToInt32(). It seems Int.Parse is not able to convert and also make sure that SeriolNO is not blank.

    http://stackoverflow.com/questions/2344411/how-to-convert-string-to-integer-in-c-sharp


    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Kenon-YGN Wednesday, July 31, 2013 3:58 AM
    Friday, July 26, 2013 5:59 AM
  • Hi,

    You can also use Convert.ToString() instead of applying ToString() to avoid null reference exception if you are expecting a null value here. This way you will also be able to find out if the exception is due to using Int.Parse or due to some other reason.


    Thanks, Rakesh
    Please Mark As Answer if my post solves your problem or Vote As Helpful if a post has been helpful for you. ***Posting is provided "AS IS" with no warranties, and confers no rights.

    • Proposed as answer by Mokhtar Bepari Friday, July 26, 2013 6:16 AM
    • Marked as answer by Kenon-YGN Wednesday, July 31, 2013 3:58 AM
    Friday, July 26, 2013 6:11 AM

All replies

  • Hello,

    Try to TryParse() or ToInt32(). It seems Int.Parse is not able to convert and also make sure that SeriolNO is not blank.

    http://stackoverflow.com/questions/2344411/how-to-convert-string-to-integer-in-c-sharp


    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Kenon-YGN Wednesday, July 31, 2013 3:58 AM
    Friday, July 26, 2013 5:59 AM
  • Hi,

    You can also use Convert.ToString() instead of applying ToString() to avoid null reference exception if you are expecting a null value here. This way you will also be able to find out if the exception is due to using Int.Parse or due to some other reason.


    Thanks, Rakesh
    Please Mark As Answer if my post solves your problem or Vote As Helpful if a post has been helpful for you. ***Posting is provided "AS IS" with no warranties, and confers no rights.

    • Proposed as answer by Mokhtar Bepari Friday, July 26, 2013 6:16 AM
    • Marked as answer by Kenon-YGN Wednesday, July 31, 2013 3:58 AM
    Friday, July 26, 2013 6:11 AM