Where were I? (StackTrace Class)

Posted: June 26, 2005 in Other

On my current
project we wished to impersonate a WebService for test purposes and decided to record
live messages using XmlSerialization. For the first few messages I manually implemented
code to serialize to a file. This cut-and-paste reuse obviously had to be refactored
but I was unhappy manually passing in the filename to every call of the new method
since the files are named the same as the webmethod. Somehow the generic serialization
code needed to know who called it, or to put it in Jerry’s terms it had to ask ‘Were
were I?’. Jerry replied
to my first ever blog post and finally I got a chance to use his suggestion:

http://dotnetworkaholic.com/PermaLink,guid,692ca362-89cb-4dad-985f-92aea92ca96b.aspx

http://www.codeproject.com/csharp/customtracelistener.asp

The crux is the
StackTrace class which resides in the System.Diagnostics namespace. It is exactly
as you might expect – very simple when you know it exists but I believe it would be
hard to find using Google etc.

This is the code
snippet I used after re-reading Jerry’s Code Project article:

#region Get the
calling method (“Where were I” – courtesy of Jerry Dennany)
System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace();
string methodName = “unknown”;
if (st.FrameCount > 0)
{
System.Diagnostics.StackFrame sf = st.GetFrame(1);
methodName = sf.GetMethod().Name;
}
#endregion

Being a stickler
for simplicity I read the MSDN help and reduced the code to:

#region Get the
calling method name (“Where were I” – courtesy of Jerry Dennany)
System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace(1, false);
string methodName = st.GetFrame(0).GetMethod().Name;
#endregion

I am not sure
that my employer will be sending a Mr. Dennany a check anytime soon, but I appreciated
the helpful article. This is a good reminder of why we ‘waste’ so much time with blogs.

Just a heads-up. Love or hate certifications we will likely be hearing that
next year for any senior .Net position. Even if you are already MC*.* you don’t have
this one which is coming next year:

http://www.microsoft.com/learning/mcp/architect/

I stumbled across this while researching MCDBA. Apparently if you are an already MCSD,
only two more exams are needed for an MCDBA. It is probably worth the $250 + a
couple of months study time – yes Dave I am a slow learner ;)

Two important points here:

  1. Radio Me is a term coined by Peter Day of the BBC for what was formerly known as podcasting. English media appears to bending over backward to never say the word iPod or podcasting
  2. If you have a commute more than a few miles each day and are not listening to Radio Me then stop reading right now and order a portable MP3
    player
    asap -an iRiver or an iPod are probably the best options (iPod may
    not good if you listen to music because of Apple’s iTunes store lock-in, I consume
    free podcasts + do a lot of running so the iPod mini was perfect)

Ok, you have an MP3 player. Now go and subscribe to feeds. There are many clients
out there that will auto download new ‘RadioMe transmissions’ in the way your
aggregator gathered this blog post. iPodder is
a good one to start with – it works with any mp3 player and works flawlessly
with my iPod Mini (which cannot
bookmark MP3s – aarghhh, bloody marketing – that’s why I bought it).

In a year of listening to Radio Me this is what I think all my .Net buddies
should at least try:

IT Conversations Far better than all other technical podcasts combined! Many episodes every week which are often open source focused, but we all need to know
what is happening outside of .Net. Many broadcasts are recordings from IT conferences
or interviews with extremely successful individuals. Steve Wozniak and Jerry Yang episodes
that immediately come to mind. Where else would you get to listen to people like this?
It is also interesing to realize how little Open Source people bash Microsoft
nowadays – Apple receives far worse treatement.
This Week in Tech Leo Laporte + friends from The Screensavers discuss the latest happening in Tech.
They are not 100% Geek compared to most of us ‘in the trenches’ and their minor
mistakes with details will irk you. Shortcomings aside, this bunch are very enteraining
and keep me abreast of new happenings. Presently this is a firm number two on
listening list.
.Net Rocks (AAC
Feed)
Our local hero and possibly the friendliest face in Atlanta’s .Net community Mark
Dunn
helped start this one. Since Rory left
the show it is not quite the same, but many episodes are still stellar. Ted
Neward ‘vs’ Don Box
including ORM, Java, Spring etc is great one to start
with – rest your mind before listening.
Slashdot Review Most .Net people sneer at /. Every other techy in town seems to rave about
it. IMO spending five minutes a day listening to the best posts is proving well
worth the time.
Daily Source Code Adam Curry – the Robert
Scoble
of Podcasting Radio Me. Adam is not so technical and freely
admits it. Living vicarously it feels like I experience his multi-million dollar
lifestyle a couple of days every week. He is the most entertaining podcasters out
there, yes IT Converstations will teach you much more but do give this whirl.
BBC:
From Our Own Correspondent
Since leaving Woking, England I am have become more American every day. This BBC broadcast
really reminded me of this, so I force myself to listen. It is not technical at all,
but for anyone interested in life outside of the USA give this a whirl. The BBC broadcasts
quite a few shows on RadioMe – exPats may like it, I felt almost homesick for the
first time in ten years :)

Yes, that is the list, notice how short it is? I have about ten more shows I
listen to regularly, but none I would strongly recommend to anyone else. Just like
blogs there are a many Radio Me broadcasters, but making quality audio appears
to be much harder than buying a $40 microphone – the best all have a background in
TV or Radio. Within a year I think Radio Me will have circa twenty well known
technical shows with others trying for a while then fading (back
to blogging?). As an example you have time to scan my ‘F-List’ blog in a few seconds
to evaulate if a post is worth reading. Listening takes much more effort.

Final point on in car use of MP3 players: Transmitters are OK if you are patient trying
different frequencies, but drain the battery and do drop out occasionally. I bought
a ‘Head Unit Aux Adapter’ from my dealer ($40!) + dismantled the dash and connected
it to the stock radio. I hear Best Buy etc will do the work, but personally it took
30 minutes install time which was fine apart car looking like this for a
few minutes:

This is a list of the relevant posts from msn search for Atlanta “code camp“.
I was interested in what other bloggers thought about the day, and thought
others may be too. Please send any more links you know about over and I will
update the list. The longer entries come first:

http://msmvps.com/williamryan/archive/2005/05/16/47242.aspx

http://www.solexinc.com/site/301/default.aspx

http://geekswithblogs.net/cwilliams/archive/2005/05/15/39700.aspx

http://tamasii.com/blog/archive/2005/05/17/48969.aspx

http://blogs.simplifi.com/brucet/archive/2005/05/16/181.aspx

http://weblogs.asp.net/wallym/archive/2005/05/16/406918.aspx

http://www.ipattern.com/simpleblog/


Update:
Pics (via Matt and Pat Piccolo):
http://www.imagestation.com/album/pictures.html?id=2126645832&code=16061296&mode=invite&DCMP=isc-email-AlbumInvite

Update: Installation of Aureus from SourceForge and
waiting a little over a day left Revelations.iso on my HD. Minutes later a DVD-RW
was burned and placed in my DVD player. If you are downloading Revelations wait
for the DVD download
. The effects are still impressive but at DVD quality
they do look like effects since they are too clean.

Bittorent coupled with non commercial content like this movie and the twenty plus
podcasts I listen to each week must surely have media companies rethinking their future.
How long until even my basic cable subscription is not necessary? Already cable TV
would be redundant if I (illegally) download the Simpsons etc – I know more than one
person with a modded Xbox who is doing this. Personally I prefer to stay on the right
side of the law for $40/ month, but is it really worth $40/month for a handful of
shows? Micro-payments for legal downloads of ABC News and the Simpsons would have
me calling Comcast tomorrow. I know first hand that Atlanta based cable companies
hire smart developers. I hope their strategic planners are just as smart. It interesting
to note that the BBC is already
producing podcasts
– doubt I’ll listen to live radio ever again.


News of Star
Wars Revelations
is exploding. Yesterday I finally got around to downloading it
and was pleasantly surprised.

Apparently Mr. Lucas is fine with fans making Star Wars films, so long as they are
not for profit. Take a look at the screen captures below (darn Media Player got me
for a while with overlay mode so I swiftly installed BS
Player
on the laptop + switched to RGB mode).

Any more questions on why, how much and how did you achieve this for little cash etc
are answered on the creator’s faq:
www.panicstruckpro.com/revelations/revelations_faq.html

The film is free – you will soon find torrents and direct downloads all over the web.
My mini review: sets are stellar, spacecraft are better than any of the original three
films and you will see some familiar faces like storm troopers, R2D2, regulars of
the cantina bar etc. The plots was a little weak, but if you like Star Wars you must
take a look – good luck downloading it though, my torrent did not even start whereas
podcasts often come down at up to 800k/s.

This is a huge thanks to the great folks that attended my presentation
yesterday. We had a scream, everyone seemed to be having a good time, with both the
audience and me cracking jokes – it was just like hanging out with friends except
that over 50% of the faces were new.

‘Pauls tries to Write VB Code’ could have been written as a comedy sketch – first
semicolons, then learning how to write a Dim statement. Finally an audience member
realized that I had called the demo solution IsNumeric which became the default
namespace and hence meant that using the IsNumeric keyword was not going to work.
When coding it is great to have audience of forty sharp developers looking over your
shoulder – perhaps a bit costly in real life though?

Well thanks again guys, whoever said ‘Paul Rocks’ during the applause totally made
my day. It was good to see the somewhat ‘on-the-fly’ style is working out. Preparation
for an hour long presentation used to take me close to forty hours (seriously!) but
I have it whittled down to about ten now including some dry runs. It would be easy
to recite a prepared script, but I think my ‘never-quite-the-same-twice’ style is
working out. The disadvantage is that we always miss a couple of fairly important
points during demos; still that seems a fair price to pay for having fun too.
Maybe eventually the nervousness/anxiety/ panic will totally subside and I can last
a hour without missing a beat.

If anyone is thinking of trying out presenting, then please volunteer for a 30 minute
slot at one of the study groups in town (don’t try the main .Net group first
off unless you are uber-confident!!). The first time will undoubtedly be a total
trauma – building up to the day is the worst part, the 30 minutes itself will fly
by. Once over you’ll feel great, even it was a little lame – because you will know
that you could have done better and will have increased confidence to present again.
Every presentation after that your confidence will improve and who knows you may even
start to enjoy giving them one day :) That day took a year and almost ten presentations
for me to achieve but it was worth it. Thanks guys!

Code Camp: Presentation Slides

Posted: May 14, 2005 in Other

Hopefully this presentation stirred some interest; especially in log4net. As promised here is the slide deck.

http://dotnetworkaholic.com/csharp/downloads/CodeCamp2005.ppt

Also here is the log4net cut-’and-paste everywhere’ line:

private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

For those not at the presentation that line of code uses reflection to determine the Class’s type instead of us modifying GetLogger(typeof (YourClass)) every time we declare a logger. The reflection penalty will be swallowed once in each class’ static constructor.

Probably the best resume in the world

Posted: April 24, 2005 in Other

Not to be big headed but recruiters often tell me that my resume is awesome/ best they have seen in a long time/ very impressive etc. Good job I did not let it go to my head, during today’s blog-catch-up-a-thon a stumbled across Scott Hanselman’s resume:

http://www.hanselman.com/resume/ScottHanselmanResume.htm

Can anyone beat that? Overly ambitious and hard working as I am, finding this was a real Wayne’s World I’m not worthy moment. Just looking at the hobbies section: Amateur Linguistics – Spanish, Amharic (Ethiopian), Arabic, and Bantu Languages (Ndebele, Zulu, kiSwahili). Amateur?!?! They don’t even all use our alphabet.


Check out Scott’s blog: http://www.hanselman.com/blog/

I love his posting style: generally just statements with little explanation or conclusion. Certainly challenges the grey matter. He was on DNR with Rory a few weeks ago which is how I stumbled on this gem of a blog. While listening to the show I had deja-vu of some recent interview questions when Scott’s (apparently) famous .Net interview question post was mentioned:


http://www.hanselman.com/blog/WhatGreatNETDevelopersOughtToKnowMoreNETInterviewQuestions.aspx

Basic trivia to those with long Microsoft development backgrounds, but I only learned this recently. In a nutshell Release v’s Debug simply enables/disables compilation options. With one minor tweak we can deliver Release Mode builds with Debug Symbols. Compile time and JIT optimization is not affected, but you will get lines numbers in logged stack traced traces.

Can anyone tell me why one would NOT always deploy pbd (debug symbols) files with your code other than IP issues? “Because we hate all developers and it makes Management’s day watching them debug blind” is not a valid answer.

Coupled with log4net deploying pdbs really helped me stabilize a nightmare headless process on my last assignment. What is log4net I hear many ask? Attend the first fifteen minutes of my Atlanta Code Camp presentation or read a post or two like this:

http://blogs.acceleration.net/ryan/archive/2004/11/10/380.aspx

Do I hear a few voices at the back are saying they love EIF and the MS Application Block? If you are using them already then probably stick with them as they do work, if not scan these posts and make an educated decision:

http://weblogs.asp.net/cazzu/archive/2004/05/17/133196.aspx

http://www.cauldwell.net/patrick/blog/CommentView,guid,13345.aspx

http://dotnetjunkies.com/WebLog/kenbrubaker/archive/2004/10/04/27581.aspx

There are many more posts debating EIF and log4net:

http://www.google.com/search?hl=en&lr=&q=log4net+eif

It is with great sadness that this is happening. While being involved with user groups I tried to accomplish the goal of making them a more open and inviting place for newcomers regardless of their .Net expertise. Yes the C# group is targeted towards developers/ architects with advanced knowledge, but again a core aim of mine was to prevent it being a clique of regular members.

From email feedback it appears that many people learned a great deal from my presentations. Delivering those presentations was a great help in recovering from a side effect to a Malaria vaccine called Lariam. If you are the 1 in 10,000 who gets hit by the side-effect then this is a very nasty drug and it has taken me many years to recover. No one knows how it works chemically, but the worst side effect was paralyzing fear in social situations. The technical term is fight-or-flight which translates to ‘wanting to leg it asap’ – this even happened in cubes of colleauges and at the dinner table with friends! It was quite embarrassing and at times debilitating. Anyone who saw my kick off to the mobility group was witnesses to such an episode :)

A post on Lariam is about to happen, hence I mentioned it above. Yes, posting about it publicly can only harm me – over the last few years a few individuals have used it against me in the work environment. Now I am 99% recovered I see no problems with work, but am aware some selfish individuals who read this post will use it as leverage against me. After overcoming a personal hell with the drug, I need to make a Google accessible post for new suffers to find – the first few months were utterly unbearable and if I can help any future sufferers that is worth far more than a few blows to my career.


So the reigns of the C# Group are officially handed over to the group’s ‘second in charge’ Keith Rome. Maybe later in the year I will be invited back to help the C# group out again? If not I am sure Keith will continue to take the group forward keeping the content very technical.


What I am doing with all the spare time? After a recent round of interviews with some of Atlanta’s best Architects my head will be down in books trying to catch up to their level. IMO it is easier to learn advanced material from books than user groups, but the groups can be great motivation to learn. Hopefully I will find time for cycling again and hang out with the great bunch of guys and gals I used to see before last year’s wreck.


Finally: a BIG thanks goes out to Doug and Kirk of Microsoft. They put up with a tremendous amount from us user group people and have the patience of saints dealing with some members. Please everyone try to appreciate what they do for us, and do not hassle them too much. They both go far beyond what their job asks of them.