April 2007 Entries

The .Net Days Of Old

My association with .NET started over 6 years ago. In those early days I used C++ and COM as a point of reference for everything I was learning in .NET and C#. Destructors versus finalizers, Assembly.Load versus LoadLibrary, Metadata versus COM+ attributes, and of course - memory leaks versus managed heaps. Those were fun times. I'm gearing up for a customized Pluralsight class that includes material from the Applied .NET and Applied ASP.NET 2.0 courses. I also need some perspective of a Visual Basic 6.0 developer in a .NET land. This reading list helps to re-live the days of...

Looping 101

Here is a pop quiz for language aficionados. Examine the following class: public class Foo {     public ...

Writing Technical Books

The skill of writing is to create a context in which other people can think. -- Edwin Schlossberg Jeff Atwood presents a visual contrast of two WPF books in "How Not To Write A Technical Book". I haven't read either WPF book, but Jeff's post did provoke some thinking… Color Me Code It's amazingly difficult to read code in monochrome these days. Language keywords, program comments, and string literals all blur into lumps. There is now chance to scan the source code for the important bits. Unfortunately, many publishers are unwilling to accept the higher cost of full color printing (except for technical books...

Fleeting Visions Of Doom

Your mind is racing and your fingers are struggling to keep pace. Clickety-clackety-clickety-clackety. New code, test code, refactored code – it pours across the screen. Clickety-clackety-clickety-clackety. There is no passing of time in this superb condition of lucidity. Clickety- clackety-clickety-T-T-TWACK. Opps. What was that? Something went wrong. A finger slipped! You hit the wrong combination of keys, for sure – but which keys? Was that a menu that flashed by? The intensity of that red disk light fills you with dread. Did you trigger some hidden doomsday command that is now writing 0s to the system drive? When was the last...

What's Wrong With This Code? (#14)

MSDN says the List.ForEach method will "perform the specified action on each element of the List". The following program does print out a haiku to the console, but does not make the haiku all lowercase. using System; using System.Collections.Generic; class WWWTC {     static void Main()     {         List<string> haiku = new List<string>();         haiku.Add("All software changes");         haiku.Add("Upon further reflection -");         haiku.Add("A reference to String");         // make it lowercase         haiku.ForEach(                     delegate(string s)                     {                         s = s.ToLower();                     }         );         // ... and now print it out         haiku.ForEach(                     delegate(string s)                     {                         Console.WriteLine(s);                     }         );     } }  What's wrong?  

Event Validation Errors and Network Congestion in ASP.NET

Joseph Rattz emailed me about posts I wrote last year covering ASP.NET event validation (see ASP.NET Event Validation and "Invalid Callback Or Postback Argument" Part I and Part II). In the posts I describe one scenario where an event validation exception can appear, and describe how to prevent the exception. In the scenario, client side script dynamically adds values to a list (select) control. When the user POSTs the form to the server, ASP.NET sees a new value and concludes something is wrong. The list comes back to the server with a value that wasn't present when the...

DTS in SQL 2005 - Good News and Bad News

DTS has always worried me. Unfortunately, I have 331 reasons to worry: PS > gci -r -i *.dts | group Extension Count Name ----- ---- . . . 331 .dts Five years ago, ADO.NET didn't have a bulkload API, and DTS seemed like the best tool for moving and transforming millions of records. This was despite the fact that the binary DTS packages check into source control as opaque blobs, and the cumbersome UI makes even simple changes difficult. We thought we'd need to write and distribute ~50...

The Jesse Liberty Review

My publisher pinged recently to show me Jesse's review of my WF book on Amazon.com: "Every once in a while an author is able to take a subject that others struggle with but fail to make understandable, and succeeds in making so crystal clear that it seems obvious. Allen brilliantly illuminates Windows Workflow, and his book is required reading." I've never met Jesse, but I've enjoyed his writing over the years. Coming from an expert writer like Jesse, this comment is high praise.

What ASP.NET Developers Should Know About JavaScript

"What ASP.NET Developers Should Know About JavaScript" is the title of a presentation I'll be giving at VSLive! next month. I don't plan for this to be a talk that features ASP.NET AJAX, or JavaScript data types. Instead, I want to focus on two key concepts I had to discover after I decided that I couldn't ignore client-scripting any longer: Every JavaScript function is an object. Every JavaScript function has an execution context. I think these concepts are keys to understanding modern JavaScript libraries. I hope that driving home these two concepts will let a developer understand what the following code is doing,...

Solutions With The VirtualPathProvider

The VirtualPathProvider is one of the ASP.NET pieces I looked at when 2.0 was new. I suspected then that the VPP would need a little time, but would eventually be the centerpiece of some clever solutions. Adam Kahtava has documented a number of issues he has with ASP.NET 2.0 Themes. Adam has worked around these issues by using a VirtualPathProvider. See the article descriptively entitled: "A Resolution to The Problems with Themes, Skins, and Cascading Style Sheets (CSS) - Putting the Cascades back into ASP.NET 2.0 Themes (taking control over CSS Cascades / Load Order, Media Types, and Overrides)" Piyush Shah has...

Be Wary of Page Event Handlers for Events Originating Outside The Page

A familiar question in the ASP.NET world is: "How do I show the progress of a long-running background operation?" ASP.NET AJAX has given us new tools to answer this question. It's easy to drop an UpdatePanel and a Timer inside a web form, and partially update the page when the Timer control posts back. There are still some fundamentals to remember when taking this approach, however. For example: protected void Button1_Click(object sender, EventArgs e){    HeavyDutyWorker worker = new HeavyDutyWorker ();    worker.ProgressNotification +=             new ProgressEventHandler (worker_ProgressNotification);    worker.DoWork();}void worker_ProgressNotification(object sender, ProgressEventArgs args){    Session [ProgressKey] = args.PercentComplete;        }protected void Timer1_Tick(object sender, EventArgs e){    Label1.Text = String.Format("Percent Complete = {0}", Session[ProgressKey]);}  The button click event handler creates an object...

Scott Allen
Posts - 869
Comments - 4493
Stories - 14