0

I am using wcf Service, and When I called it like below,

 try
 {
      //var of1 = CrmStartUp.GetOfferDetailsById(5070, 666, 1, 2016, 18);
      LostReasonsByOffer lostReasonsByOffer145 = CrmStartUp.GetLostReasonsByOffer(5070);
 }
 catch (Exception ex)
 {
 }

then I got

nullreference Exception

and it is not caught by the SystemException Class. Can anyone tell me where I am going wrong or How to fix this issue.

the error is shown below

enter image description here

Usman
  • 4,615
  • 2
  • 17
  • 33
  • Check threads when execution stops. It might happen that the uncaught exception was thrown on a different thread - just guessing, but worth checking. – Zoran Horvat Dec 16 '16 at 11:05
  • Post the *full* exception, including its call stack. You can get it easily with `Exception.ToString()`. Almost certainly the error occurs somewhere else – Panagiotis Kanavos Dec 16 '16 at 11:11
  • 2
    BTW the image doesn't show that the exception isn't caught. That's the image *before* jumping to the exception handler. BTW, such handlers are a very bad idea - like sticking a circuit breaker to the up position instead of fixing a short circuit – Panagiotis Kanavos Dec 16 '16 at 11:13

1 Answers1

1

Are you certain that it isn't being caught? It could just be showing up in the debugger due to your visual studio settings as per this answer

Visual Studio: How to break on handled exceptions?

You could either try running it in a "release" configuration rather than the "debug" configuration, not running it in the debugger or changing your visual studio debug settings.

That's the only thing that springs to mind.

EDIT: As Panagiotis Kanavos notes, it's also worth highlighting that an empty catch block is most often a bad practice.

Community
  • 1
  • 1
Goody
  • 381
  • 1
  • 2
  • 10