March 2004 - Posts

Creating a Simplified Asynchronous Call Pattern for Windows Forms Applications

By way of a blog entry, David Hill explains how you can implement an asynchronous call pattern that allows you to consume Web services from a Windows Forms application without having to worry about threads.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwinforms/html/SACP_WinForms.asp

=======================================================

This is exactly something I need for our Client! We consume Web Services from our Server product, and this makes the experience all the more seamless.

Personal World Travel Site

Nice personal travel map site pointed out by Paul Edwards about the travel site http://www.world66.com 

Here is mine :D

Reading part of the 'Image' Sql Server BLOB

I am storing an ammount of files, of different types, as BLOBs in my Sql Server 2000 database.

Some of these are XML files, inside of which are some addresses I'd like to read.

However, I don't want to download a 2MB JPG image from the db, just to find out it isn't an XML file!

My best solution after playing around was to extract the first 5 bytes from the data, to determine if I should go ahead and use the whole thing:


// Get the 'Image' SQL Type

SqlDataReader sqlDataReader = selectDataCommand.ExecuteReader(CommandBehavior.SequentialAccess);

// If successful

if(sqlDataReader.Read())

{

             int bufferSize = 5;

             byte[] outbyte = new byte[bufferSize];

              long startIndex = 0;

             // Read the first 5 bytes

             long retval = sqlDataReader.GetBytes(0, startIndex, outbyte, 0, bufferSize);

            // Translate bytes to string

           string test = FromASCIIByteArray(outbyte);

           // Do the first 5 characters match an XML header?

           if(test.CompareTo("<?xml") == 0)

           {

                     // Get entire file here

           }

}


This is quicker, but I know it can't be the quickest way. I am trying to find out how to write a stored prodecure that will do the same on the SQL Server side.

And yes, I could just add an extra byte column to my table to designate the file as XML, but I am interested in how to parse Image data types on the SQL Side.

I'll update when I find out how :)

'Whidby' delayed

It looks like I really will have to get NAnt working, or wait until 2005 for the Microsoft MSBuild in the next version of Visual Studio!

http://www.crn.com/sections/BreakingNews/dailyarchives.asp?ArticleID=48536

I think NAnt may be a far more mature project by then anyway, and I am looking forward to get involved with this community.

Automated build tools for C#

I'm in charge of our build machine, and the tool I have been using up until now is Buildit from Sapient: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/tdlg_app.asp

I guess for small projects it is fine, but I'm really looking for something on the enterprise level.

What I need to do is:

1) Build our Web Services application in C#

2) Build the administrator console in ASP.Net

3) Build our client product for TabletPC in C#

4) Get the latest source code for the above from our Visual Sourcesafe database

5) Place them into nicely packaged, ready to use Install MSI files, without any confusion for the poor marketing guys

 

Buildit achieves this, but I can't really perfect the process. The problem is that it invokes Visual Studio.Net from the command line to do all its building work, and sometimes it doesn't shut down properly meaning that I have to manually kill the process. Also sometimes it marks the produced binary as 'read only', meaning it can't be archived and overwritten.

In effect, it is usable, the configuration file is short, but it is no way automated!

It comes with source code, but there is almost no support information out there. Yes, I could work it out, debug and fix it.. but it isn't open source, so the changes would just benefit me, and anyway, it stops being an easy to use automated build tool with so much effort!

One interesting development is the MSBuild tool coming in the forthcoming Whidby: http://msdn.microsoft.com/Longhorn/toolsamp/default.aspx

It looks very nice and configurable, but I don't want to play with the beta I have (this is our production server).

Therefore... I have decided to try Nant: http://nant.sourceforge.net/

It is based on Ant http://ant.apache.org/ which I loved in my last job to quickly run up Java builds. I'm hoping that this conversion will work as well for me.

Nant (& Ant) use very flexible Xml files to describe a build, and will allow me later to use unit testing.

I'll record my progress on line!

Ensuring a single instance of your .Net application

Very simple article on how to use a Mutex to keep your . Net application as a single running instance.

http://www.ai.uga.edu/mc/SingleInstance.html

This is relevant to me since I am developing a Tablet based application, and that pen is really not easy to use! Users frequently stab the screen so much that two or three instances are not uncommon.

Icon for your website

I'm starting this blog off with a link to minor feature of Internet Explorer (and others) that adds an icon to your website's entry in the 'Favorites' menu.

http://www.wpdfd.com/editorial/wpd0304review.htm#footnote

At the end of the day, quality is about all the little things that improve the user experience. If this helps the user scan the favorites list even one second quicker, its worth it.