The views expressed on this weblog are mine alone and do not necessarily reflect the views of my employer.
 Wednesday, June 11, 2003
Figuring out which DLLHost.exe belongs to which COM+ Application
I wanted to find out what is inside of a particular DLLHost.exe.   I went into Component Services and used "View|Status" do see the PIDs of each COM+ Application which I can then correlate to a PID in Task Manager.  Shouldn't there be a COM+ Explorer/Spy/Info Application for this, or did I miss it?
Updated Link to this post 5:45:50 PM  #    comment []  trackback []
"Parsing a culture-aware DateTime" or "Avoiding InStr"

Say you've a black-box application that you can't change that is culture-ignorant and returns a date as a string that looks like this:

6/11/2003 1:56:31 PM

but your client wants it output like this

11-Jun-03 01:56:31 PM

Sometimes folks ask me "What's the best way to parse a Date string in .NET?"  Often they are old school VBA-type folk and they are really saying "I'm going to use InStr() to parse this date unless you stop me."

So, here's a better way, IMHO.  I believe in avoiding Mid$, InStr, strstr, etc...it's just not my business to parse strings.  This is, of course, not the only way, but a possible way.  (Certainly the CultureInfo should be cached, things could be better localized, etc):

System.IFormatProvider format = new System.Globalization.CultureInfo("en-US", true);
DateTime lastLogin = DateTime.Parse(Session["lastSignOn"].ToString(),format);
lblLastLogin.Text = String.Format("Your last login was: {0}", lastLogin.ToString("dd-MMM-yy hh:mm:ss tt"));

Note that we know we are getting a the string as a U.S. formatted date time, we pass in our CultureInfo object that implements IFormatProvider to DateTime.Parse, then pass it our custom Format String to the new DateTime object's ToString(). 

This is the kind of higher level layer of abstraction that allows me to focus on business and avoid work.  Parsing DateTimes is administrivia...it's lame-o work.  The Marketects at Microsoft say "Do more with less" but I prefer my own saying "Do more business, do less work."

Put it down sir...step away from the manual string parsing code...no need for strstr() here...


Updated Link to this post 2:25:16 PM  #    comment []  trackback []
Bitter XML Quote of the Day

"Without an XML Schema, you might as well replace all those < and > signs with quotes and commas, 'cuz that's what you've got - just less-than/greater-than-delimited text."

I'll be presenting this rant and many other as a PADNUG Web Services SIG meeting sometime this year in a presentation loosely titled: "Mailing a Boot: Exactly how NOT to use XML and Web Services"

Certainly schema isn't required, but when you spend the date passing DateTimes and decimals around in XML, you get used to clients of your XML using the associated schema for simple data typing. 


Updated Link to this post 2:07:37 PM  #    comment []  trackback []