Pitfalls of Automatic Update Utilities

Usually I’m a proponent of Microsoft. I generally like their developmet tools, and enjoy writing in .NET because of all the useful things I can accomplish with it. But today they pissed me off a little bit. I was trying to figure out how to interface with Exchange Server 2003, so I downloaded their SDK for 2003 (http://www.microsoft.com/downloads/details.aspx?familyid=09B45603-2147-424E-81E5-601FBFDFDF0D&displaylang=en). One of the sample projects is an Issue Tracking System.

The install went ok (it creates a virtual directory for you, and copies the files to your inetpub folder). However, when I opened the site in Visual Studio 2005 it was prompted with the conversion utility to upgrade it to the new 2005 format. “No problem” I thought, go for it. I navigated to the IIS directory (using the Visual Studio IIS browser in the conversion utility) and clicked ok.

I was letting it run and glanced down at the status bar to see files names from a lot of my other projects flying by. “Oh crap!”, said to myself…actually that wasn’t exactly what I said. I clicked cancel, which didn’t work. I guess they didn’t use enough application.doevents in their code.

Long story short, a lot of my applications that used to be stored in my inetpub folder are now hosed. Thankfully all the real project are under source control so I just have to pull fresh copies out, but a lot of little test projects are now broken.

Maybe I have something unique about my environment which caused it to attempt to convert my entire inetpub folder, or maybe I fat-fingered the “open from IIS application” browser and selected the IIS root. Whatever it was it’s a very good reminder lesson that:

  • Conversion utilities are dangerous things
  • Source Control is awesome
  • Backup procedures are critical

Now I’m off to try and salvage as many applications as I can……

ADAL 1.0.7a

Not much to report, just that I accidently removed the icon for the ADAL exe, so the last release went out without it. So if you really were attached to that awesome icon, you can go re-download ADAL.

-Andrew

ADAL 1.0.7

 You can download now, or read and download at the bottom (recommended, lol)

ADAL Version 1.0.7 was released today. Additions and fixes are included are:

– Fixed bug in PopulateFromReader that caused an error when calling the SELECT method of DAL objects. The call to PopulateFromReader was not inside a Do While Reader.Read.

– Supports SQL Server IMAGE and MONEY datatypes. Image is mapped to a Byte array on the .NET side.

– Added detection of IsNullable and IsComputed when building the DAL.

– IsComputed detection is used to fix the bug that resulted when ADAL tried to update computed columns. Also, the ClassItem object’s property is set to read-only on a computed column. So there is never even the illusion that the end user could try to update that column themselves.

– IsNullable is used to reduce the amount of code generated in the .NET Insert and Update methods.

– We added screenshots to the SourceForge website too!

Download?

Dynamic Javascript Tag Insert – ASP.NET 2.0

A lot of JavaScript utilities need to be inserted at the bottom of the page so that the HTML elements that use them (or at least the function calls) do not generate errors. When using ASP.NET 2.0 master pages, you might want to insert the <SCRIPT> tags dynamically so that a particular JavaScript resource is available on every page.

I spent a lot of time trying to find a solution to this, and never really found a perfect one. The method I describe here is the best solution I could find at the moment.

Firts add a PlaceHolder Control, right before the end form tag. We’ll use this to write the <SCRIPT> tag so that it appears almost at the end of the document:

<asp:PlaceHolder ID=”plhJavaScript” runat=”server”></asp:PlaceHolder>

Then you can modify the master page’s Page_Load event to create a generic control, which will end up as the <SCRIPT> tag that is our goal. Once you have it, all you have to do is add it to the placeholder:

‘create generic html control

Dim JS As New HtmlControls.HtmlGenericControl(“script”)

JS.Attributes.Add(“type”, “text/javascript”)

JS.Attributes.Add(“src”, HttpContext.Current.Request.ApplicationPath & “/js/MyJavascriptFile.js”)

plhJavaScript.Controls.Add(JS)

That’s pretty much it. I think the code above might need tweaking to get the path always perfect if you’re down in a sub-directory, but you get the point.