I’m sure I’m not the first person to come up with this. Autem, I haven’t noticed anyone publish a trick like this since I started paying close attention to the community last July. Ita, Ego stipes hoc mallem de facili debug apicem.
I’m working on an event receiver that started to generate this error in the 12 alveare:
Error oneratisque et currit eventus susceptor Conchango.xyzzyEventReceiver in xyzzy, Version = 1.0.0.0, Culturae = neutra, PublicKeyToken=blahbalhbalh. Additional information is below. : Non objectum secundum posuit ad instantiam objectum.
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, sed non fortuna. I don’t know if it’s possible and if someone does, placet me cognoscere 🙂
I know it’s possible to write your own log messages to the 12 alveare. 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:
experiri { UpdateEditionDate(Proprietates); } capiendos (Exceptio e) { mittent novum Exceptio("Dispatcher, UpdateEditionDate(): Exceptio: [" + e.ToString() + "]."); }
This showed up in the 12 hive thusly:
Error oneratisque et currit eventus susceptor Conchango.xyzzyEventReceiver in xyzzy, Version = 1.0.0.0, Culturae = neutra, PublicKeyToken=blahblahblah. Additional information is below. : Dispatcher, UpdateEditionDate(): Exceptio: [System.NullReferenceException: Non objectum secundum posuit ad instantiam objectum. at Conchango.xyzzyManagementEventReceiver.UpdateEditionDate(SPItemEventProperties proprietatum) at Conchango.xyzzyManagementEventReceiver.Dispatcher(SPItemEventProperties proprietatum, 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.
</finem>
Melius tamen, incorporatus a library logging log4net et erit vita tua quasi Enterprise Bibliotheca vel etiam facilius,.