advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Download the sample TimeServer application.
Partners & Affiliates
advertisement
advertisement
Rate this item | 0 users have rated this item.
 Print Print
 
Simplify .NET Debugging with SmartInspect
Debugging is hard enough—even without the complications involved in debugging multithreaded programs—so tools that can simplify your debugging tasks are definitely worth evaluating. SmartInspect lets you log and view any type of data, and is particularly useful for multithreaded debugging tasks. 

advertisement
fficient software debugging is definitely an acquired talent. Most programmers have some ideas on how to do it when they first get started but typically can't handle a large complex program that doesn't work. Add multithreading to a complex program and you're sure to lose most junior software developers.


In the "old days" the only way to debug a program was to put in a bunch of print statements, or the language appropriate equivalent, interspersed with the rest of the code to dump out variables and let you know where the program got to before it crashed. This method still works well for any language without a suitable debugger.

SmartInspect from Gurock Software uses a mixture of old-fashioned techniques with tight Visual Studio integration to help ease the pain of debugging multithreaded applications. Today's version of the old print statements writes messages into a log file. The advantage of a log file is that you can typically put enough information there to help you find out what's going on—and you can make logging a feature that can be turned on or off via configuration in a production deployment of your application.

Installation and Setup
Installing SmartInspect takes only a few minutes and adds a single icon to your desktop to access the console program. To use the product with your projects, you'll need to perform this three-step process.

 
Figure 1. The Project Property Pages: This is where you add the Gurock.SmartInspect namespace as an import for your project.
  1. You must add a reference to the SmartInspect.dll. To do that, right click the References item in the Solution Explorer, browse to the folder where you installed the program, and select the SmartInspect.dll file.
  2. Add SmartInspect to the import list by right-clicking on your root project item in Solution Explorer and selecting Properties. From the Properties page, select "Imports," and then enter "Gurock.SmartInspect" in the namespace edit box (see Figure 1).
  3. Enabling SmartInspect in your project requires a single line of code in the form load method. In VB.NET, this line should look like:
   SiAuto.Si.Enabled = True

After enabling SmartInspect, you have two choices for debugging code—you can debug through the SmartInspect console or exclusively through log files. The console is great for initial development and testing but it isn't something you'd want to leave in a production program. During development however, using the console for debugging sessions is much easier than wading through log files.

You can use either the TCP/IP protocol for real-time logging (the default) or specify a log file, for example:

   SiAuto.Si.Connections = @"file(filename=c:\log.sil)";

The console can load a specified log file or receive the logging information via TCP/IP. For production use it's better to use log files, especially for a commercial app where support is likely to be offsite.

The best way to enable debugging for a production application is to use the LoadConnections method of the SmartInspect class. With this method, support staff can send a preconfigured connections file to the customer to enable logging. Here's an example of using the LoadConnections method:

   SiAuto.Si.LoadConnections(@"c:\connections.sic");

In the example above, if you had deployed an application with a customer that was having problems, you could have the customer place a preconfigured connections file called connections.sic in the c:\ folder, thus enabling logging and directing the log output to a destination specified in the connections file. You can then use the log contents to debug the deployed application. Logging will remain disabled if SmartInspect can't find the specified connections file, or if the file doesn't contain a valid connection string.

The code that logs a message works with both the console and log file output. SmartInspect provides two additional methods, EnterMethod and LeaveMethod, that let you know when a program enters or leaves a method. The console also provides a button so you can display the call stack to trace program execution paths easily. Here's a code snippet from the downloadable TimeServer sample program showing several different log methods:

   SiAuto.Main.LogMessage("Calculating minutes/seconds");
   
   int minutes = DateTime.Now.Minute;
   int seconds = DateTime.Now.Second;
   
   SiAuto.Main.LogValue("seconds", seconds);
   SiAuto.Main.LogDateTime("System Time", 
      System.DateTime.Now);
   int index = minutes / seconds;
   
   SiAuto.Main.LogMessage("Sending date to client.");
   
   w.WriteLine(DateTime.Now.ToString());
               
   for( int j = 0; j<1024; j++)
      buffer[j] = (byte) (j * 431);
   SiAuto.Main.LogBinary("Byte Array",buffer,0,1024);

  Next Page: Debugging with SmartInspect


Page 1: IntroductionPage 2: Debugging with SmartInspect
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
IBM eBook: Planning a Service Oriented Architecture
IBM eBook: Choosing the Right Architecture--What It Means for You and Your Business
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Avaya Article: Using Intelligent Presence to Create Smarter Business Applications
Intel Go Parallel Article: Getting Started with TBB on Windows
Microsoft Article: 7.0, Microsoft's Lucky Version?
Avaya Article: How to Feed Data into the Avaya Event Processor
IBM Article: Developing a Software Policy for Your Organization
Microsoft Article: Managing Virtual Machines with Microsoft System Center
Intel Go Parallel Article: Intel Threading Tools and OpenMP
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
HP Video: StorageWorks EVA4400 and Oracle
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Red Gate Download: SQL Toolbelt and free High-Performance SQL Code eBook
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
Silverlight 2 App and Walkthrough: Leverage Silverlight 2 with SQL Server and XML
IBM Article: Enterprise Search--Do You Know What's Out There?
HP Demo: StorageWorks EVA4400
Microsoft Article: The Progress and Promise of Deep Zoom
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES