ఇంకా మరొక ఈవెంట్ స్వీకర్త డీబగ్ ట్రిక్

I’m sure I’m not the first person to come up with this. అయితే, I haven’t noticed anyone publish a trick like this since I started paying close attention to the community last July. ఈ విధంగా, నేను ఈ త్వరితంగా మరియు సులభంగా డీబగ్ చిట్కా పోస్ట్ ఇష్టం ఆలోచన.

I’m working on an event receiver that started to generate this error in the 12 అందులో నివశించే తేనెటీగలు:

Xyzzy లోపం లోడ్ మరియు పరుగు పందెం రిసీవర్ Conchango.xyzzyEventReceiver, సంచిక = మాత్రం దానిని 1.0.0.0, సంస్కృతి = తటస్థ, PublicKeyToken=blahbalhbalh. Additional information is below. : ఆబ్జెక్ట్ సూచన ఒక వస్తువు యొక్క సందర్భానికి సెట్ కాదు.

I didn’t know where I had introduced this bug because I had done too many things in one of my code/deploy/test cycles.

I tried this solution to get my pdb in there with hopes that SharePoint’s 12 hive would show the stack trace, but no luck. I don’t know if it’s possible and if someone does, నాకు తెలపండి 🙂

I know it’s possible to write your own log messages to the 12 అందులో నివశించే తేనెటీగలు. Frankly, I wanted something a little less scary and quicker to implement.

It occurred to me that I could at least get some basic trace information by catching and re-throwing generic exceptions like this:

  ప్రయత్నించండి {
    UpdateEditionDate(లక్షణాలు);
  }
  పట్టుకొను (మినహాయింపు e)
  {
    రువ్వు కొత్త మినహాయింపు("Dispatcher, UpdateEditionDate(): మినహాయింపు: [" + e.ToString() + "].");
  }

This showed up in the 12 hive thusly:

Xyzzy లోపం లోడ్ మరియు పరుగు పందెం రిసీవర్ Conchango.xyzzyEventReceiver, సంచిక = మాత్రం దానిని 1.0.0.0, సంస్కృతి = తటస్థ, PublicKeyToken=blahblahblah. Additional information is below. : పంపిణీదారుకు, UpdateEditionDate(): మినహాయింపు: [System.NullReferenceException: ఆబ్జెక్ట్ సూచన ఒక వస్తువు యొక్క సందర్భానికి సెట్ కాదు. at Conchango.xyzzyManagementEventReceiver.UpdateEditionDate(SPItemEventProperties లక్షణాలు) at Conchango.xyzzyManagementEventReceiver.Dispatcher(SPItemEventProperties లక్షణాలు, String eventDescription)].

That gave me all the detail I needed to track down that particular problem and I expect to use it a lot going forward.

</చివర>

నా బ్లాగ్ సబ్స్క్రయిబ్!

3 "న ఆలోచనలుఇంకా మరొక ఈవెంట్ స్వీకర్త డీబగ్ ట్రిక్

  1. Anders Rask
    I have had alot of luck lately debugging this kind of issues with a combination of SPTraceView and DebugView
    Debugview alone is very usefull as well. You can pipe out output using System.Diagnostics.Debug.WriteLine().
    You dont even have to remove them when you release build, since the output only is triggered in debug build mode.
    SPTraceView is a tool created by Hristo Pavlov.
    At its default setting it will show you ULS trace events as they happen. And it catches also the ULS trace events that *doesnt* make it to the diagnostics log!
    But that i disable as soon as i run the util. Whats much better is that you can pipe output to show up in DebugView.
    It also has alot of nice features for filtering on event levels, services etc.
    hth
    Anders
    oh and nice seeing you in the bar at SPBP 🙂

ఒక Reply వదిలి చార్లెస్ ప్రత్యుత్తరం రద్దు

మీ ఇమెయిల్ చిరునామా ప్రచురితమైన కాదు. లు గుర్తించబడతాయి *