Monthly Archives: November 2010

Storing URLs With Query Strings In XML

Suppose you have a URL like  http://www.test.com?1=2&2=3 and you need to store it in an XML file like the one below.  The & character will cause and error.  Replace the & with & e.g. http://www.test.com?1=2&2=3

<?xml version=”1.0″ encoding=”utf-8″ ?>
<Regions>
<Europe>
<Region ID=”1981″ Name=”Denmark” IAURL=”http://www.test.com?1=2&2=3/>
</Europe>
</Regions>

 

 

Forcing An Application Uninstall

I had an issue where an application was erroring every time I tried to open it.  I tried to uninstall the application, but this failed as the source files were no longer available.  I tried to install the latest version of the app, but this failed because an older version was still installed!  Having downloaded many of the free uninstall utilities and got no where I decided a brute force approach was worth trying.  Searching through the registry I found the entry for the application:

HKEY_CURRENT_USER\Software\Microsoft\Installer\Products\10EAF4144327A104B8D4CB44666B4DCE

I wanted to trick the new version of the app so it couldn’t tell I had an older version already installed.  I renamed the above registry key to:

HKEY_CURRENT_USER\Software\Microsoft\Installer\Products\10EAF4144327A104B8D4CB44666B4DCE-OLD

The new version of the application installed perfectly and has been working ever since.  This technique may not work with all applications and should be a last resort, but it worked for me.

Retrieving A List Of VMs With Checkpoints In System Center Virtual Machine Manger 2008 R2

If you’re using System Center Virtual Machine Manger 2008 R2 (SCVMM) and need a list of virtual machines with checkpoints, you can do this with a simple PowerShell command.  From within the SCVMM console click on the PowerShell icon (see below) and run the command: Get-VMCheckPoint .  Further information about the Get-VMCheckPoint command is available by running: Get-help Get-VMCheckPoint

Debugging Applications Using The Red Gate .NET Reflector

An application that transfers users’ time from our time recording system to our accounts system was failing to run.  A support call had been logged with the supplier, but it was taking too long to get a fix.  Looking in the error log for the application I could see:

01/11/2010 15:15:00 Connected to: DTE
01/11/2010 15:15:30 Error Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

In the same folder as the failing exe was a config file.  Inside the config file were the URLs for two web services as well as some stored procedure names.  I checked the webservice URLS and they loaded fine, so the error was probably with one of the stored procedures.  I knew the application was written in C#, so I used the Red Gate .NET Reflector http://www.red-gate.com/products/reflector/ to open the exe so I could take a look at the source code.  I searched for “Connected to:” and went to the section of code that was causing the problem.  I could now see the stored procedure the application was running.  I started SQL Server Management Studio and opened the stored procedure to see what it was doing.  It took the form:

INSERT TABLENAME

SELECT…..

Running the SELECT statement took 31 seconds, checking this against the error log showed the application was timing out in 30 seconds.  A quick check of the source code in .NET Reflector showed the code was using a SqlDataAdapter Select command.  The default timeout for the Select command is 30 seconds.  I altered the stored procedure to run in batches, which took less that 30 seconds.  Running the application showed this had fixed the problem.  Next step, get the application developers to introduce a more permanent fix….