Scott Hanselman

Sairama's Interesting Code of the Day - Printing Line Numbers while Debugging C#

February 19, 2003 Comment on this post [1] Posted in Web Services
Sponsored By

In C++ if problems happen, we'll want to log the error along with filename and Line Numbers, often like:

CString strCompleteMessage;
strCompleteMessage.Format(_T("%s , HRESULT %0x [%s,%d]"),strMessage,hr,A2W(__FILE__),__LINE__);
LogInfo(strCompleteMessage);

In C#, there are no such macros so we use the StackFrame class. Below we show how to print the filename and line numbers while logging messages/errors.

     public static void foo()
     {
     // some operations here
     // some error here
     string msg = "Unable to do xyz operation, Please report this to abc@xyz.com";

     // true means get the file information also ( needs pdb files which can be generated for Release builds )

     StackFrame CallStack = new StackFrame(0, true);
     Console.WriteLine("Error:{0} occurred in:{1} in File: {2} at Line: {3}", msg, CallStack.GetMethod(), CallStack.GetFileName(), CallStack.GetFileLineNumber() );
}

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Microsoft aquires Connectix - VMWare screwed?

February 19, 2003 Comment on this post [0] Posted in Web Services
Sponsored By

update Microsoft is acquiring some assets of Connectix, including an unreleased server program and software that permits Windows to run on a Macintosh. [News.com]

Interesting, since Microsoft has a universal license for VMWare for all MS employees.  I've never used the Connectix product, but I guess I will soon!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Outlook2RSS v0.4 with support for Images

February 18, 2003 Comment on this post [0] Posted in Web Services | Tools
Sponsored By

Jorge Curioso and I have updated Outlook2RSS (download here) (modified from Peter Drayton's Google2RSS) to include additional features in RSS 0.93 as well as support for Inline Images and Attachments from within Outlook!  This means, you can include inline images from within Outlook and with a little magic (very little) we will deal with all the Outlook cid://ABCE32432 crazy URLs and munge the content appropriately.  The images will be extracted from Outlook into the same directory as the RSS feed with the external URLs automatically added.

Jorge is happily running his blog with Outlook2RSS and has added a "Publish Blog" tool to his standard Outlook Toolbar.  You too can have you own blog from Outlook...just create RSS from a private or public Outlook folder and style to taste.

Next step, make it an add-in...here's a thought - Greg, how about using this code to implement an "Export to RSS" feature in NewsGator so we can both aggregate feeds and publish feeds from any Outlook Folder?  You've got all the infrastructure already...I'd like to have it run on the same schedule, and it'd only be one extra tab...;)

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

BBSs, Dead OSs, and Door Games

February 18, 2003 Comment on this post [1] Posted in Gaming
Sponsored By

Rogers Cadenhead reminds us of our BBS days...

This month marks the 25th birthday of the bulletin board system, the old-school online network invented by Ward Christensen and Randy Suess.
As someone who began using a BBS in 1981 and claims to have invented the BBS door game, I could inflict all kinds of punishing remembrances.
You kids today got it good. Back then we transmitted our data over acoustic modems at 300 bits per second. And we were grateful!

Ah...to be young and foolish!  I remember running my BBS out of my parent's garage (what computer geek didn't live in their parent's garage?).  I was doing contract programming on Windows 3.1, back when Hello World! was 93 lines of C and SDK code.  I started out running Wildcat BBS software and a pile of door games (thanks Rogers!)  I multi-tasked with the help of QEMM and Desqview.  Then I moved up to OS/2 and a Digiboard.  At the peak of Tweak Computer Support BBS we were running multiple lines happily on a single 486 with 8 megs.  I started at 1200bps, but when it ended, I think I was just looking at a sweet new USR 9600 v.Everything.

Rogers:  You might take a look at http://www.telery.com/, they let you play classic BBS Door Games on the 21st century 'Net!  GO Tradewars!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

SQL2K Stored Procedure Debugging broken with SP3

February 18, 2003 Comment on this post [2] Posted in Web Services | Bugs
Sponsored By

Some folks have noticed that Stored Procedure Debugging was not working after applying SP3 to SQL Server 2000.  If you run into this, the trick is to call

exec sp_sdidebug "legacy_on"

This is a new security switch that was added in SP3 and only affects App Debugging.  Also, note that the setting doesn't stick, and you'll need to call it each time you start up the SQL 2K Server.

 

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.