Wednesday, December 30, 2009

S3 Organizer Dialog?

I am copying some of the functionality from this dialog in the S3 Organizer.  I don’t think I will copy these instructions:


S3 Organzier



WCF with no app.config

I did a Service Reference in my .NET C# assembly and got the infrastructure for a fully enabled WCF proxy.  I also got a app.config file added to my project that I didn’t want.  I need to run configuration free since I am running in both COM+ and managed mode (i.e. some public classes are COMVisible and some are Managed), plus my COMVisible classes are hosted in COM+.  So I need to get ride of the app.config which looks like this:


<?xml version="1.0" encoding="utf-8" ?>
        <binding name="AmazonS3SoapBinding" closeTimeout="00:01:00"
            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
            allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
            messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
      <endpoint address="" binding="basicHttpBinding"
          bindingConfiguration="AmazonS3SoapBinding" contract="AmazonS3.AmazonS3"
          name="AmazonS3" />

I replaced it with a method like this:

private AmazonS3.AmazonS3 CreateChannel()
    BasicHttpBinding wsHttpBinding = new BasicHttpBinding();
    wsHttpBinding.Name = "dynamicBinding";
    wsHttpBinding.Security.Mode = BasicHttpSecurityMode.Transport;
    wsHttpBinding.TextEncoding = Encoding.UTF8;
    wsHttpBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
    wsHttpBinding.AllowCookies = false;
    wsHttpBinding.MessageEncoding = WSMessageEncoding.Text;
    wsHttpBinding.UseDefaultWebProxy = true;
    wsHttpBinding.OpenTimeout = new TimeSpan(0, 1, 0);
    wsHttpBinding.ReceiveTimeout = new TimeSpan(0, 10, 0);
    wsHttpBinding.MaxBufferPoolSize = 524288;
    wsHttpBinding.MaxReceivedMessageSize = 65536;
    EndpointAddress endpointAddress = new EndpointAddress(AmazonUrl);
    ChannelFactory<AmazonS3.AmazonS3> channelFactory = new ChannelFactory<AmazonS3.AmazonS3>(
        wsHttpBinding, endpointAddress);
    return (channelFactory.CreateChannel());

I am not a WCF expert, however this code works and not I can delete the app.config.


Monday, December 28, 2009

Debugging 0x80070002

0x80070002 is the error code returned when a FileNotFoundException (HRESULT COR_E_FILENOTFOUND) is thrown in managed code.  Basically, there is a missing file that your managed code expects.


In my case I was getting this when I tried to install a component in COM+ (Component Services) where the COM object was written in C#.  However, I didn’t have a method defined as with a [ComRegisterFunctionAttribute], so how could my code throw a file not found exception?  The issue was that my assembly relied on other assemblies that where not present.  Which lead to a binding problem when install the component in COM+, so it was the CLR that was throwing the exception not my code.


To make matter’s worse, I was trying to install the component during an MSI installation.  The .log file from msi just showed an 0x80070002 error.  To find the issue I used the Assembly Bind Log Viewer (FUSLOGVW.exe) found in the Windows SDK.  While the MSI installer ran, The Assembly Bind Viewer was tracking which assemblies where not binding correctly, and keeping a log of them.  This allowed me to figure out what MSI was doing, and where the 0x80070002 was coming from.



Saturday, December 26, 2009

What is 0x80131501?

When managed code with a COM interface throws a SecurityException the return value (HRESULT) is 0x80131501.  This can happen on a regsvr32.exe (or regasm.exe) or on any method call to the COM interface.



Linking Leaf Nodes In Google Search

I run a travel and tourist site for San Juan Island  A long time ago we wrote up reviews for all the islands, the major towns, and the high tourism attractions.  The site is structured this way:




We also create a Google Site map giving the home page has the highest priority, the islands the next highest, the cities a lower priority and the individual write-ups the lowest priority.  All pretty standard.  However, when we started to look at the reports from Google Webmaster Tools we saw something very disturbing:




We were telling Google about 220 pages, however only 93 had been indexed.  Why was this?  We presumed it was because there where no external links to the leaf pages (the individual reviews of restaurants, parks, beaches, and trails).  Google crawler was doing exactly what we asked, traverse the high priority pages in the site map and leave the low priority pages.  The leaf pages (the reviews) that were linked externally where being indexed, however Google was assuming the rest where not worth the effort (or room to index).  Since the majority of our traffic was directly coming to the reviews from Google search, we need to figure out a way to get all the reviews listed in Google index.


What we decide to do was blog about all the new additions to the web site, when we posted a new review, then we wanted to tell the world about it, blog it.  Basically the web site itself is a reference site, structured in a tree.  However, what we needed was a news sites, that told people what was going on with the structure.  So we create Blog ( Blog).   This was created on Blogger ( 


It took Google 5 days to traverse the blog (we link to it from the bottom of every page on  The this is what Google crawler found: Link Results For Blog.  Once Google crawler found the page, it took another 24 hours for the link to the main site to appear in Google’s search results.  Success.


Currently we are avoiding the temptation to add all the reviews to the blog that are missing from Google search.  Just doing the newly added reviews to the web site.



Amazon EC2 for Windows The Basics – Part VI

The size of Elastic Block Storage (EBS) on Amazon EC2 is charge by the size of the formatted drive, not the size of data on the drive.  In the case of the Windows-Server2008-i386-Base-v101 this is a 30 Gigabytes (the primary hard drive).  Which you pay for regardless if you are using all of it or not. 


This is different the the dynamically expanding .vhds that are used in Windows Virtual Server. 


EBS storage is allocated all at once to avoid disk fragmentation and poor storage.



Saturday, December 19, 2009

Amazon EC2 for Windows The Basics – Part V

What is Elastic Block Storage (EBS)? When the Amazon web site describes EBS there is a lot of references about mounting and raw block storage -- Linux terms. However, with the new boot from EBS for Windows this is a confusing. So from a Windows perspective I am going to try to explain EBS and touch on why boot from EBS is the only way to go for Windows.

Windows doesn't really have a concept of mounting hard drives, and the operating system likes all physical drives to be in place before it boots. Which means that when Amazon EC2 boots your Windows instance it needs to know what storage (drives) are attached.  Keep this in mind as you read on.

In Microsoft Virtual server we think about this as a .vhd drive. All the virtual hard drives are attached when the Virtual instance is started.

Back to Amazon EC2, there are two types of storage (drives) available. ESB drives and Amazon Machine Images (AMI). Amazon Machine Images are stored on the Amazon S3 cloud, and moved to the Amazon EC2 servers when the EC2 instance is booted. Previous to December 3rd 2009, you could only boot off an AMI. Here are the steps for creating a Amazon EC2 instance that booted off an AMI:

1) Choose a operating system pre-installed on a AMI from the list.
2) Boot your Amazon EC2 instance and wait for the System log to tell you that Windows is ready.
3) Log in via RDC and do some stuff.
4) Shutdown your Amazon EC2 instance
5) Save that AMI that was running on Amazon EC2 datacenter to Amazon S3, which is a slow process.
6) Register the AMI instance with Amazon EC2, so that EC2 knows where in S3 to fetch the image from. 
6) Terminate the instance running on Amazon EC2, which removes the storage from the EC2 data center.

When you wanted to restart that AMI:

1) Choose your AMI image to boot from the registered AMI list. 
2) Your image is copied from Amazon S3 to The EC2 data center, this tends to be very slow -- up to 20 minutes.

3) The image is booted and now you can log in.
4) Once you are done using EC2 instance, you have to repeat the steps to save it off to the Amazon S3 cloud.


AMI instances where impractical for two reasons: they where slow to transfer between the EC2 datacenter and Amazon S3, which meant saving them and retrieve them was a tremendous act of patience.  The second reason is that they where limited to 10 gigabytes.  Which is enough to run a web server, however using it for almost anything else was impractical. 


Before December 3rd, 2009, Amazon solution to the problems was the allocation of EBS for a secondary drive from the main drive booting AMI image.  EBS is permanent storage of from 1 gigabyte to 1 terabyte in the Amazon EC2 datacenter.  This second drive (think d: drive) didn’t need to be copied from Amazon S3 so it was available instantly when the operating system booted and it could be much bigger then the 10 Gigabyte limit of the AMI boot image.  However, this didn’t work for Windows operating system.  Most of the strain on the 10 gigabyte main  (c:) drive was from Windows updates and program installation, which typically require that they be installed on the c: drive (under Program Files).  Secondly, as pointed out above windows needs to know the permanent drives before it boots, and there are no device drivers for EBS drives.  Which left Windows operators doing some pretty convoluted stuff to figure out how to get a little more storage from EBS drives.  All in all it wasn’t worth the effort.


“On December 3rd Amazon announced that you could boot from Elastic Block Storage (EBS)”


What this meant is that Amazon provided a few pre-installed images of the Windows operating system (and Linux) that where on EBS.  Booting from these worked like this:


1) Choose a operating system pre-installed on a EBS from the list.
2) Boot your Amazon EC2 instance and wait for the System log to tell you that Windows is ready.
3) Log in via RDC and do some stuff.
4) Shutdown your Amazon EC2 instance  -- do not terminate.

That is it.  Your personal EBS (a copy of the pre-installed EBS) stayed in the EC2 data center.  When shutdown the instance is not charge the CPU fee, just the storage fee.  An when you start it the next time it starts much faster since it doesn’t need to be copied from S3. 


However, the pre-installed EBS image you choose has a fixed hard disk size.  I am running the medium instance of the Windows 2003 basic, it was installed on a 30 Gigabyte EBS, which is plenty for what I am doing.  Basically, Amazon had to make a choice about the EBS size before they installed the operating system.  Coming from the Virtual Server 2005 world I find myself a little spoiled.  In Virtual Server you could have dynamically expanding drives that increased their storage (up to 256 Gigabytes) as you used the storage (wrote more to the disk).  In the EBS world you have a fixed pre-allocated size of the hard disk.


Booting from EBS makes running the Windows operating system practical on Amazon EC2.  It is my recommendation that you always choose a EBS image to boot from.



Friday, December 11, 2009

Shortcut of a Shortcut

There is no such thing as a shortcut to a shortcut in the Windows File System.  If you create a shortcut from a shortcut then you just get a shortcut to the original target.  You can programmatically create a shortcut to a shortcut using CLSID_ShellLink, however Windows will not render the icon correctly, or navigate the end target correctly.





You can not call IShellLink method SetPath with a full parsable path to a namespace extension in Windows 7.  Instead you have to call IShellLink SetIDList.  Once you have set the id list and save the .lnk file via IPersistFile Save method the shortcut will find your namespace extension (on open).  However, CLSID_ShellLink is unable to render the Image via IExtraceImage for the link if the link is to an image (or other file type that supports IExtractImage).  Instead it renders the default icon for your perceived type.  It asks your namespace extension for the perceived type via IShellFolder2::GetDetailsOf.



Monday, December 7, 2009

Creating a Windows Build Server On Amazon EC2

My definition of a build server is a standalone box that has been configured so that it can build a release of your software with one command.  The server typically has compilers, install packing software, and is dedicated to the task of building a release.  Questions from the Joel Test that a build server needs to answer in the affirmative:

Build in one step?

Daily builds? 


My build scripts, that run on the build server, perform these tasks:

  1. Clean the Build Directories
  2. Checkout all the source files from source control.
  3. Compile all the source.
  4. Package the binaries and assemblies into installations (setup.exe)
  5. Deploy the installations to the download location on the web sever.
  6. Update a database (web content server) with version information, download location etc…

Over the years, I built different types of build servers, and written many build scripts.  Ten years ago, I had dedicated build servers.  Lately, I use virtual machines hosted on top of Virtual Server 2005.  Since I am moving everything to the cloud,  I wanted to use Amazon EC2 for Windows as my build server. 


One reason I choose Amazon EC2 is that my source control hosting company is and they use Amazon EC2 and S3.  Because they are on S3, data transfer between my EC2 server and S3 is free and is very fast.  The installations in step 5 are going back to my S3 account (for download by my users) so those are also free of transfer charges.  However, regardless of where you are hosting your source control,


“If your source control is externally hosted on the Internet, an EC2 build server is the next step.”


I tried to do this several months ago, however the 10 Gigabyte limitation on the Amazon Machine Image (AMI) and the slow boot times of a saved AMI made it impossible.  Several days ago Amazon announced that you could create a 30 Gigabyte Elastic Block Store (ESB) instance on EC2.  The ESB start and stop much easier then the AMI.  This is the feature I needed to make this project work.  10 Gigabytes is enough to run the IIS web server and a web site, but in order to get everything else (Visual Studio installed, my source, and have room to compile), I need that 30 Gigabyte ESB instance.  It took me 2 days to create the build server.  Most of the time was spent installing software and configuring my build script to run remotely. 


Here are the steps:


Creating a Key Pair

  1. Open the AWS Management Console
  2. Choose Key Pairs.
  3. Press the button to Create a Key Pair
  4. Enter a name, like Build, and press Create.
  5. If you are like me and running Internet Explorer, you will get a download file yellow warning ribbon at the top of your browser.  Choose to Download File, however the Ajax of the AWS Management Console doesn’t work well here, which means that this Key Pair is lost (you need to get that file)
  6. Delete the key pair you just created.
  7. Without closing the browser, repeat the steps again.  This time the file will download.  Save it to a very safe place.

Once you create a key pair, you will not have to do it again.  Now you need to create an instance.


Launch a Default Instance

  1. Choose AMIs and select the filter at the top to view “ESB images” (with operating system already installed)
  2. Choose “ami-ba22c0d3”, which is labeled: amazon/Windows-Server2003R2-i386-Base-v108
  3. Right click and choose “Launch Instance”. 
  4. Walk through the wizard using the key pair you created.
  5. You want 1 instance of the High-CPU Medium instance type.
  6. You do not need CloudWatch monitoring.  Amazon CloudWatch is a web service that provides monitoring for AWS cloud resources, starting with Amazon.  For a build server where it is required that it not always be up CloudWatch is not needed.
  7. Press the Launch Button.

Launch Instance Wizard


Once you launch your instance, you need to wait for it to start.   Go back to the instance list in the AWS Management console and look for your booting instance.   Keep checking the System Log (right click System Log) until it says Windows is Ready to use and has a password line.  It is not ready if it is blank – all black.


System Log


Getting You Administrator Password

Once the instance is booted, it has a separated virtualized disk just for you.


“The local Administrator password that is just for your instance.”


This password is not what you see in the System Log.  The password in the System Log plus your key pair decrypt into the Administrator password.

  1. In the AWS Management console right click on your instance and choose “Get Windows Password”.
  2. Open your key pair file that you downloaded and copy the whole contents into your clipboard.
  3. Paste the clipboard in the text area that is presented in the window from the AWS Management Console.
  4. Press decrypt password

Retrieve Default Windows Administator Password

If you reset your password the next time you login, that will be the last time you have to do that.


Logging in With Remote Desktop

“All access to a Windows EC2 image is done via remote desktop connection.”

Remote desktop is a utility that you have on your Windows operating system in the Accessories folder.  The first thing is figure out the DNS that Amazon has allocated for your instance.  It is one of the columns in the instance list, or if you want to copy it into your clipboard:

  1. In the AWS Management Console, right click on the instance.
  2. Choose Connect from the drop down menu.
  3. Highlight the DNS Name and copy it into your clipboard
  4. Once you have the DNS name in your clipboard, open a session of Remote Desktop and paste in the DNS name.
  5. Login with “Administrator” and the password you decrypted.

Console Connect


Change the Password

The next step is to change the password so you don’t have to remember or decrypt the default Amazon password.  Once you are logged in, you can do this by clicking on the Windows Security option from the Start menu.


Run Windows Updates

First thing you want to do with every new machine is run Windows updates.  There have been many security updates since Windows 2003 R2.  This is a good time to mention:  when you shutdown your ESB Windows you are not charged for CPU time (however you are charged for the storage of the image).  Rebooting your instance (like you have to do when you run Windows Updates) doesn’t make it disappear.


“The only way to lose the ESB  image is to Terminate it via the AWS Management console.”


You do not want to terminate unless you want to start again from scratch.  Shutting down Windows makes your instance shutdown.  So when you are done for the day, just shut Windows down and the ESB instance will be there for you to launch the next day.  You are billed by the whole hour, so it doesn’t make sense (with a ten minute boot up time) to shut it down when you go to lunch.


Remember that after each reboot forced on you by Windows update, you need to rerun the Windows updates until it tells you there is no more updates.  This is Windows 2003 and it will not do all the updates at once.


Installing Software

First thing I need to create a build machine is an install of Visual Studio 2008.  However, there is no CD-ROM drive.


  “Everything that you want to install on your EC2 instance needs to be downloaded to it.”


Since I am an MSDN subscriber I can download the Visual Studio 2008 .iso directly from the web site to the EC2 instance and save it on a file on the hard disk.  Downloads are amazingly fast to the EC2 instance.  Amazon has a great pipe to the Internet and the ESB image writes fast, much faster than a .vhd in Virtual Server 2005.


Once I have the .iso on the hard disk, I need to mount it to install.   I am using a free installation of DAEMON tools lite.  If you use the custom install option you can opt out of the installation changing your home page, your default search provider and install a toolbar in Internet explorer.  Once you have their software installed and you reboot, you can mount your .iso and it appears like a DVD under your computer in Windows explorer.


Daemon Tools Lite


The next thing I need to install is InstallShield 2008, which I have on DVD.  To do this, I use Amazon S3 Organizer, a plug-in for Firefox and upload the whole DVD to a bucket on Amazon S3 from my desktop computer.  Then I install Firefox and Amazon S3 Organizer on the running EC2 instance and download the whole DVD to a directory on the C:\ drive.  The only issue is that S3 Organizer won’t transfer zero byte files from S3 to the hard drive and the InstallSheild installation has about 20 files with nothing in them.  I solve this problem by taking the error list of zero byte files from the S3 Organizer and creating 20 files by hand on the hard drive – that are empty.  Fortunately the install works from the directory without having to be run from a root.


Getting the Source Files

Checking out the source from my build script (a batch file) requires that I have an SVN client installed.  This is because, my source control repository, supports SVN.  I use Silk SVN 1.6 which is free and I can download directly to the EC2 instance.  The command I add to the batch file look like this:


svn.exe update  --non-interactive


Since I have already checked out the repository to the build root, svn.exe knows what repository to pull the files from.  Because uses S3, updating the files is amazingly fast.


Moving the Installations Off the Server

Once I have the installations created using the InstallShield product, I need to move them to a location where my users can download them.  Since I want to shut down the build machine after I am done building, they need to move off of this machine.  I chose to place them in my Amazon S3 bucket, and make them as publically available.  Anyone can download them directly from Amazon’s servers.  To do this, I needed to write some C# code that copied the files to the right location.  I created a C# console application called BuildHelper.exe that took in a number of parameters and created a unique file path and name for each installation that the build script created.  The BuildHelper.exe project was added to the list of projects I was building and is compiled every time the build script ran.


The command line in the build script batch file looks like this:


echo "BuildHelper.exe" /publish /filename "bigDrive_S3_%1.%2.%3.%4_0600_x86.exe" /filepath "%INSTALLDIR%\Installation\AmazonS3\AmazonS3\WindowsVista\DiskImages\DISK1\setup.exe" /os "Windows Vista" /platform "x86" /productline "BigDrive" /product "BigDrive for Amazon S3" /major %1 /minor %2 /build %3 /intraday %4


%1 %2 %3 %4 are the version parameters passed into the batch file.  Each build is has a different version number.  /filepath is the location of the setup.exe file.  /filename is the new name in the Amazon S3 bucket.  I have one of these lines for each operating system and installation created.


Updating The Version Database

At the end of my build script, I am in a really good spot. The assemblies are compiled. I have a setup.exe and it has been deployed where users can download it.  The build script “knows” that everything has happened successfully, the version of the release, and what was released.  Now I need it to “tell” my version database this information so that the external web site is updated correctly.  However, the build server can not access the version database.  The version database is behind my firewall in the company data center, and the EC2 image is out on the Internet and is going to be shut down. 


To update the database I added another method to BuildHelper.exe that makes an HTTP  REST API call to  our  external website.  The REST API is configured to accept the version number, product name, platform etc… and update the internal version database.  The database is updated with a public column bit turned off, so that the release doesn’t appear on the web site until we are ready to deploy it.


Shutting Down

Once the build is completed, I shut down the Windows 2003 Server, which shuts down the EC2 instance and the clock stops running.  The whole process takes about 30 minutes. 



Friday, December 4, 2009

Amazon EC2 for Windows The Basics – Part IV

There is a lot of documentation about running Amazon EC2 and if you are having trouble Amazon will quickly direct you to the forums for questions, however there isn’t really a resource from a Windows centric developer to other Windows gurus.  As I 20 year Window veteran, I am going to try to fill that gap with a few blog posts entitled “Amazon EC2 for Windows The Basics”


The second thing I do when install a new windows server is to run Windows Update. 


“The second thing that you need to do on your EC2 instance is install the Windows updates.”


The Windows 2003 R2 instances from ESB are recent to the R2 of Windows 2003, however there are a lot of security hot fixes released since R2.  I like to have them all applied.  It is fairly painless since Amazon amazing download times.


Remember this is Windows 2003, so you need to go back to Windows Update every time it makes you reboot until there are no more updates to install.



Amazon EC2 for Windows The Basics – Part III

There is a lot of documentation about running Amazon EC2 and if you are having trouble Amazon will quickly direct you to the forums for questions, however there isn’t really a resource from a Windows centric developer to other Windows gurus.  As I 20 year Window veteran, I am going to try to fill that gap with a few blog posts entitled “Amazon EC2 for Windows The Basics”


Once you have your instance boot, you have retrieved the administrator login from the AWS management console, successfully connected to the server via RDC.


“The first thing to do when you get logged in is change the administrator password”


Amazon provides a good secure password for the administrator account – it is obvious there is a lot of thought put into security.  However, it is a pain in the butt to get the password the first time and to log in.  So changing the password saves you a lot of time on the next boot of the instance.


If you are using Windows you probably already know that you can’t copy and paste your password into the window's login box.  That box doesn’t support copy and paste.  When you have a long password like Amazon initializes the instance with it can sometimes be frustrating to get it right.  However, there is a work around in RDC to help you copy and paste the password.


1) Open Remote Desktop Connection.

2) Choose Options >>.

3) Then check the “Allow me to Save credentials” checkbox.


Remote Descktop Connection


4) Click Connect

5) The next dialog which is design to allow you to save your password you can copy and paste into the password line.


Windows Security


This allows you easily to copy/paste from the AWS Management console into the login box making first time remote desktop access faster.



Amazon EC2 For Windows The Basics – Part II

There is a lot of documentation about running Amazon EC2 and if you are having trouble Amazon will quickly direct you to the forums for questions, however there isn’t really a resource from a Windows centric developer to other Windows gurus.  As I 20 year Window veteran, I am going to try to fill that gap with a few blog posts entitled “Amazon EC2 for Windows The Basics”


I know it is suppose to work, and I know this will get fixed.  However, as of December 2009:


“Sometimes windows instances do not start.”


I don’t want to be negative or point out a bug, however it is really frustrating when you don’t know this might be the case and it happens to you.  It is less frustrating it you know this might happen and what do about it.


The first thing is to figure out if the instance started or not.  The way to do this is look at the system log from the AWS management console.  It should look like something like this:


System Log


It should say: “Windows is Ready to use” and it should have a password entry.  If is blank then the instance didn’t start correct.


The password entry is very important.  If you are starting a new instance from one of the provided Amazon EBSs or AMIs then the instance will come with a preset administrator password that can be decrypted with your key pair that you created to start that instance.  The AWS Management consoles reads the password from the System Log and it gives you an option of decrypting the password.  If you don’t get this password line in the System Log then the “Get Windows Password:” option will come up with a blank dialog.  Without the password line you can’t get the administrator password to log into the box.   If you are booting one of your saved AMIs or EBSs then you already know the password and don’t need this line.


Watch the system log for updates. That being said


“You will need to wait for the instance to start, up to 5 minutes for an ESB image.”


Even after the management console says the instance is in the started, it still takes a few minutes to get the required output in the system log.  After ten minutes you need to reboot the instance – only if you know the password or the system log has displayed the password.  Rebooting a instance that hasn’t displayed the password will not help.  Rebooting doesn’t reset the password.


If you see a blank System log and have waited 10 minutes (for an ESB image), then you need to terminate and restart.  If you see the password in the System Log, however not the “Windows is Ready to use” then you can try rebooting (which works better then terminating).


Saved AIM images that have been saved to your S3 account can take up to 20 minutes to boot.



Amazon EC2 for Windows The Basics – Part I

There is a lot of documentation about running Amazon EC2 and if you are having trouble Amazon will quickly direct you to the forums for questions, however there isn’t really a resource from a Windows centric developer to other Windows gurus.  As I 20 year Window veteran, I am going to try to fill that gap with a few blog posts entitled “Amazon EC2 for Windows The Basics”


For me EC2 is all about replacing servers with cloud computing and when I get rid of my old servers it is my Linux friends that take them.  As Windows IT we always buy the latest and greatest servers and they seem super fast when we buy them.  I get good mileage out of my servers, usually 5 to 10 years.  However, when I go to sell them it seems that they only fetch $50.  However, there is always some Linux geek ready to snatch it up and replace a Pentium 3 server he has in his basement.  Doing so he brags: “I can run 500 web sites on this server” and off he goes into his cave.   The point of this rabble: Windows needs more server horsepower then Linux and yes to their benefit Linux geeks can get more from less.


“When running a EC2 instance for Windows never choose the small type of instance”


When you go to launch an instance you are given a choice between small (m1.small, 1.7GB) and medium (c1.medium, 1.7GB)* .  Choose the medium instance.


Medium instances boot faster, install faster, and run faster.  It is not like the regular and premium gasoline at the gas station, medium instances are faster.  You can compare it to a 4 cylinder automobile and a 6 cylinder.  For me the savings in time is worth the price.




* These are the instance types at the time of writing, December 2009.

Thursday, December 3, 2009

Every Exception Has A Unique GUID

If you know me you will know that I love GUIDs and use them for everything.  One of the things I use them for is to create a unique identifier to error messages in my code.  I have override the Exception class adding my own method that looks like this:


public ProviderException(System.Guid error, string message, Exception innerException)
    : base(String.Format(CultureInfo.CurrentCulture, "{{{0}}}: {1}", error.ToString(), message, innerException))


Basically, anytime that I want to throw an exception in my code, I do so with a unique GUID.  The calling code looks like this:


catch(SoapException soapException)

    throw (new ProviderException(new Guid("{513EEF48-8C02-4135-9344-2A401EAF2112}"), soapException.Message, soapException));



I have the option of creating my own message, and I always pass the exception I am trapping as the inner exception.  Notice that I have a hard coded GUID in my code.  It is not Guid.NewGuid() – since this would create a different GUID every time the error happened.  What I want is a unqiue identifier to the error line in the code.


My client application catches all the errors and presents the user with this dialog:




Notice the more information link at the bottom of the dialog.  If the user’s click on this link a browser window is open to:


Which is an ASP.NET MVC page with more information about this issue and a forum for user discussion.  This allows my company to update the error information without having the user upgrade their installed application.  It also allows us to post solutions on the web site.


The user can also do a search for the error message using the GUID and see everyone else that has blogged, commented, or complained about the error.


Notice also that I might not know all the errors that will happen in my application or how often, however I can get statistics on how many times the error information is requested from the web site, focusing my bug fixing efforts for the next revision.



Wednesday, December 2, 2009

Batch File Bug

This is the code I have:


cd %PROJECTROOTLOCAL%\Installation\AmazonS3\AmazonS3\
del  /s /f /q *.*


What I want to do is delete all files in the Installation\AmazonS3\AmazonS3 directory.  However what if the directory doesn’t exist?  Well I get this error on the first line:

The system cannot find the path specified.


And the current directory isn’t changed.  Which leaves me at the root of the my project.  Which means that the second command deletes all the files in my project.  Not good.  The fix is this:


mkdir %PROJECTROOTLOCAL%\Installation\AmazonS3\AmazonS3\
cd %PROJECTROOTLOCAL%\Installation\AmazonS3\AmazonS3\
del  /s /f /q *.*


Or is there something better?



Tuesday, December 1, 2009

ShortCut Syntax For Command Line

Here is the shortcut syntax I use to get a command line at a particular directory: %windir%\system32\cmd.exe /K "cd \My Projects\BigDrive\trunk\Version 1.0\" This is helpful for having a shortcut pinned to the start menu that opens a command line directly to directory where I run my build commands for my projects. {6230289B-5BEE-409e-932A-2F01FA407A92}