tag:blogger.com,1999:blog-30707273409825589562024-03-05T05:20:48.520+00:00Steal FocusCallum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.comBlogger106125tag:blogger.com,1999:blog-3070727340982558956.post-25074962713470628932013-01-21T20:00:00.000+00:002013-01-21T20:00:00.543+00:00StealFocus Forecast - ability to delete cloud services not on a white list.<span style="background-color: white; font-family: Verdana, sans-serif; font-size: 16px;">Following on from previous posts </span><span style="background-color: white; font-family: Verdana, sans-serif; font-size: 16px;">about the StealFocus Forecast application, the application can now delete deployments of Azure hosted services that are not on a white list.</span><br />
<span style="background-color: white; font-family: Verdana, sans-serif; font-size: 16px;"><br /></span>
<span style="background-color: white; font-family: Verdana, sans-serif; font-size: 16px;">Continuing the theme of the previous posts, the Forecast application is about controlling your costs for cloud services.</span><br />
<span style="background-color: white; font-family: Verdana, sans-serif; font-size: 16px;"><br /></span>
<span style="background-color: white; font-family: Verdana, sans-serif; font-size: 16px;">So far the application can create or delete hosted services on a schedule (deleting services when they are not used saves you money), delete storage entities on a schedule (deleting unused storage saves you money) and horizontally scale hosted services in or out on a schedule (scaling in hosted services during periods of low demand also saves you money).</span><br />
<span style="background-color: white; font-family: Verdana, sans-serif; font-size: 16px;"><br /></span>
<span style="background-color: white; font-family: Verdana, sans-serif; font-size: 16px;">Now the application will find any hosted service deployments that are not on a white list and will delete them. This also presents you with a cost saving as you will not be on the receiving end of unplanned growth of the number of hosted services you are running.</span><br />
<span style="background-color: white; font-family: Verdana, sans-serif; font-size: 16px;"><br /></span>
<span style="background-color: white; font-family: Verdana, sans-serif; font-size: 16px;">You can configure the white list as follows:</span><br />
<span style="background-color: white; font-family: Verdana, sans-serif; font-size: 16px;"><br /></span>
<br />
<pre style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;"><span style="color: blue;"> <</span><span style="color: #a31515;">whiteList</span><span style="color: blue;"> </span>
<span style="color: blue;"> </span><span style="color: red;">pollingIntervalInMinutes</span><span style="color: blue;">=</span>"<span style="color: blue;">60</span>"
<span style="color: blue;"> </span><span style="color: red;">includeDeploymentDeleteServices</span><span style="color: blue;">=</span>"<span style="color: blue;">true</span>"
<span style="color: blue;"> </span><span style="color: red;">includeDeploymentCreateServices</span><span style="color: blue;">=</span>"<span style="color: blue;">true</span>"<span style="color: blue;"> </span>
<span style="color: blue;"> </span><span style="color: red;">includeHorizontalScaleServices</span><span style="color: blue;">=</span>"<span style="color: blue;">true</span>"<span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">service</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">myAzureServiceName1</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">service</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">myAzureServiceName2</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">whiteList</span><span style="color: blue;">></span></pre>
<br />
<span style="background-color: white; font-family: Verdana, sans-serif; font-size: 16px;"><br /></span>
<span style="font-family: Verdana, sans-serif;">The attributes ("includeHorizontalScaleServices" etc) indicate whether those other configured services should be automatically included in the white list (the configuration is truncated for brevity and is missing those additional configuration elements).</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">The application will look for hosted services attached to the configured subscription(s). The subscription configuration is also excluded for brevity.</span><br />
<span style="font-family: Verdana, sans-serif;"><br /></span>
<span style="font-family: Verdana, sans-serif;">An example of a full configuration file is included with the application download.</span><br />
<span style="background-color: white; font-family: Verdana, sans-serif; font-size: 16px;"><br /></span>
<span style="background-color: white; font-family: Verdana, sans-serif; font-size: 16px;">For more information look at the </span><a href="https://github.com/StealFocus/Forecast" style="background-color: white; color: #999999; font-family: Verdana, sans-serif; font-size: 16px; text-decoration: initial;" target="_blank">home page on GitHub</a><span style="background-color: white; font-family: Verdana, sans-serif; font-size: 16px;">.</span>Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-37987525188483494172013-01-14T20:00:00.000+00:002013-01-14T20:00:00.813+00:00StealFocus Forecast - ability to horizontally scale cloud services on a scheduleFollowing on from my <a href="http://callumhibbert.blogspot.co.uk/2012/12/cloud-forecast_10.html" target="_blank">previous post</a> about the StealFocus Forecast application, the application can now horizontally scale a configured number of Azure applications on a schedule.<br />
<br />
Just to recap, "Forecast" is an application that can be installed as a Windows service and will perform various operations on your Windows Azure applications according to the configuration. For example it can create or delete hosted services on a schedule. The principal driver for this is to save money, being able to remove hosted services when they are not being used and spin them up later (e.g. test environments) can be a big money saver.<br />
<br />
A similar principal applies to horizontally scaling your application on a schedule. You can configure the Forecast application to scale out your application(s) during a certain time period (when there is anticipated high demand) and then scale back in later (during quiet periods). Minimising the number of running instances also presents the opportunity for cost savings.<br />
<br />
To horizontally scale a Windows Azure application on a schedule, it is configured as follows:<br />
<br />
<br />
<pre style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;"><span style="color: blue;"> <</span><span style="color: #a31515;">scheduledHorizontalScale</span>
<span style="color: blue;"> </span><span style="color: red;">id</span><span style="color: blue;">=</span>"<span style="color: blue;">myArbitraryId</span>"
<span style="color: blue;"> </span><span style="color: red;">subscriptionConfigurationId</span><span style="color: blue;">=</span>"<span style="color: blue;">myArbitraryAzureSubscriptionName</span>"
<span style="color: blue;"> </span><span style="color: red;">serviceName</span><span style="color: blue;">=</span>"<span style="color: blue;">myAzureServiceName</span>"
<span style="color: blue;"> </span><span style="color: red;">deploymentSlot</span><span style="color: blue;">=</span>"<span style="color: blue;">Production</span>"
<span style="color: blue;"> </span><span style="color: red;">treatWarningsAsError</span><span style="color: blue;">=</span>"<span style="color: blue;">true</span>"
<span style="color: blue;"> </span><span style="color: red;">mode</span><span style="color: blue;">=</span>"<span style="color: blue;">Auto</span>"
<span style="color: blue;"> </span><span style="color: red;">pollingIntervalInMinutes</span><span style="color: blue;">=</span>"<span style="color: blue;">30</span>"<span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">horizontalScales</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">horizontalScale</span><span style="color: blue;"> </span><span style="color: red;">roleName</span><span style="color: blue;">=</span>"<span style="color: blue;">myAzureServiceRoleName1</span>"<span style="color: blue;"> </span><span style="color: red;">instanceCount</span><span style="color: blue;">=</span>"<span style="color: blue;">2</span>"<span style="color: blue;"> /></span></pre>
<pre style="background-color: white; font-family: Consolas; font-size: 13px;"><span style="color: blue;"> <</span><span style="color: #a31515;">horizontalScale</span><span style="color: blue;"> </span><span style="color: red;">roleName</span><span style="color: blue;">=</span>"<span style="color: blue;">myAzureServiceRoleName2</span>"<span style="color: blue;"> </span><span style="color: red;">instanceCount</span><span style="color: blue;">=</span>"<span style="color: blue;">4</span>"<span style="color: blue;"> /></span></pre>
<pre style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;"><span style="color: blue;"> </</span><span style="color: #a31515;">horizontalScales</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">schedules</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">schedule</span><span style="color: blue;"> </span><span style="color: red;">scheduleDefinitionName</span><span style="color: blue;">=</span>"<span style="color: blue;">BusinessHours</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">schedules</span><span style="color: blue;">></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">scheduledHorizontalScale</span><span style="color: blue;">></span></pre>
<br />
<br />
You can have multiple entries (one for each service) and multiple schedules for each individual service.<br />
<br />
A future feature will scale the application on demand, according the performance metrics.<br />
<br />
For more information look at the <a href="https://github.com/StealFocus/Forecast" target="_blank">home page on GitHub</a>.Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-89388689394271389272012-12-17T20:00:00.000+00:002012-12-17T20:00:01.638+00:00Diagnosing problems with Process Explorer<br />
I recently upgraded an instance of Team Foundation Server 2010 to the 2012 version. The core upgrade process went very smoothly. The problem came with my customised build templates which used a custom activity written in C#. I was expecting one error, which I tried to fix before even attempting a build. This first error was that my custom activity was written against the TFS 2010 client assemblies:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">Microsoft.TeamFoundation.Build.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</span><br />
<span style="font-family: Courier New, Courier, monospace;">Microsoft.TeamFoundation.Build.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</span><br />
<span style="font-family: Courier New, Courier, monospace;">Microsoft.TeamFoundation.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</span><br />
<span style="font-family: Courier New, Courier, monospace;">Microsoft.TeamFoundation.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</span><br />
<span style="font-family: Courier New, Courier, monospace;">Microsoft.TeamFoundation.WorkItemTracking.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</span><br />
<br />
These had to be changed to the TFS 2012 (Version 11.0.0.0) assemblies. So I upgraded and rebuilt the assembly holding my custom activity.<br />
<br />
However, running a build after the upgrading my custom activity still gave me an error:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">TF215097: An error occurred while initializing a build for build definition \[Team Project Name]\[My Build Name]: Cannot create unknown type '{clr-namespace:StealFocus.TfsExtensions.Workflow.Activities;assembly=StealFocus.TfsExtensions}UpdateBuildNumber'.</span><br />
<br />
For some reason my "UpdateBuildNumber" class could not be created. That type could not even be found.<br />
<br />
Time to poke around and see what is happening.<br />
<br />
After checking some obvious things (were all dependencies available on the Build Agent, checking <a href="http://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.100).aspx" target="_blank">Fusion Log</a> etc), I used Process Explorer (<a href="http://technet.microsoft.com/en-gb/sysinternals/bb896653.aspx">http://technet.microsoft.com/en-gb/sysinternals/bb896653.aspx</a>) to look at the "TFSBuildServiceHost.exe" process and see if my assembly was even loading.<br />
<br />
Starting up Process Explorer, I got a list of all processes on the local machine. I know I'm looking for "TFSBuildServiceHost.exe" as that is the executable for the Team Build service.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZ24FvUY3QDy04lSZaNuLr3yn1RFPyO6441RGZ9cCaJ8GR8XzFXWpeX9btxg9E_mMshklSZdUR-D_hn99CwPpQcfKH7Fg_ZBHmXm_B97zDTMq_WZu2edjRPfkVy_mCaSF3ZnGBBLCvKmI/s1600/ProcessExplorer1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="268" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZ24FvUY3QDy04lSZaNuLr3yn1RFPyO6441RGZ9cCaJ8GR8XzFXWpeX9btxg9E_mMshklSZdUR-D_hn99CwPpQcfKH7Fg_ZBHmXm_B97zDTMq_WZu2edjRPfkVy_mCaSF3ZnGBBLCvKmI/s640/ProcessExplorer1.jpg" width="640" /></a></div>
<br />
I can look at the detail of "TFSBuildServiceHost.exe", including all loaded .NET assemblies.<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHtHO4SQdp7TUPU6W1QTxEv_lUbA_xcqu2fYndf3_ikqebLbmGHQIrbcHCQci5uIqdGqGbo1IB428B0VOL1jBO4H3SZB9xA4cW1zuNmsLkwoHnDiN_rnHqKUbnwXUv7rRgFKvPojAr_v0/s1600/ProcessExplorer2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHtHO4SQdp7TUPU6W1QTxEv_lUbA_xcqu2fYndf3_ikqebLbmGHQIrbcHCQci5uIqdGqGbo1IB428B0VOL1jBO4H3SZB9xA4cW1zuNmsLkwoHnDiN_rnHqKUbnwXUv7rRgFKvPojAr_v0/s640/ProcessExplorer2.jpg" width="640" /></a></div>
<br />
Looking down the list of loaded assemblies, my "StealFocus.TfsExtensions.dll" (which holds my custom activity) is not loaded at all, so it looks like there's quite a fundamental problem.<br />
<br />
The thought occurred to me that I compiled my upgraded custom assembly against .NET 4.5, perhaps the TFS Build Agent is a .NET 4.0 application. This would mean the TFS Build Agent would be unable to load my assembly. As a rule of thumb, a .NET application cannot load assemblies from a later .NET Framework version. As an aside, the CLR version indicated as "v4.0.30319.17929" in the information above is misleading, the .NET Framework 4.5 still uses the CLR v4.0. The CLR saying "v4.0.30319.17929" did not mean it was a .NET 4.0 application.<br />
<br />
So I rebuilt my upgraded assembly against .NET 4.0 and the build completed successfully. Looking into the detail with Process Explorer once more, I saw the following:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNrR1_ncpAhMwlFQA8aCtHjomw-wypTNyXj7gphAtzrv2DWZCKRJiROXXLCIQm2qYlGb__X0qH_2-VESa_LctIVukF7gxXX0ICW-TWc9d6mpfUab6oPxrkNTGW-JxszYaq9aSvJjI_Jfo/s1600/ProcessExplorer3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="308" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNrR1_ncpAhMwlFQA8aCtHjomw-wypTNyXj7gphAtzrv2DWZCKRJiROXXLCIQm2qYlGb__X0qH_2-VESa_LctIVukF7gxXX0ICW-TWc9d6mpfUab6oPxrkNTGW-JxszYaq9aSvJjI_Jfo/s640/ProcessExplorer3.jpg" width="640" /></a></div>
<br />
My assembly ("StealFocus.TfsExtensions.dll") had indeed loaded.<br />
<br />
Problem solved.<br />
<br />
So Process Explorer was a very useful tool to see what was happening under the hood. It showed me that my assembly was not loaded, which triggered my thought process about .NET Framework versions.Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-15036291408054088232012-12-10T20:00:00.002+00:002012-12-10T20:00:05.143+00:00Cloud "Forecast"?<br />
It's worth re-capping a couple of points from my <a href="http://callumhibbert.blogspot.co.uk/2011/11/windows-azure-and-operational-cost.html" target="_blank">previous post</a> talking about operational cost reduction using Windows Azure. A key benefit of using the cloud is the ability to quickly and easily tear down environments, this includes test environments. If you are not using a test environment, then simply delete it and recreate it later when you need it. This can give you very large cost reductions.<br />
<br />
With this in mind, I have created an application that will automatically tear down (or create) cloud resources on a schedule. The application can be run as a console or installed as a windows service.<br />
<br />
At the moment you can:<br />
<ul>
<li>Delete "Hosted Services" on a schedule.</li>
<li>Create "Hosted Services" on a schedule.</li>
<li>Delete Storage Tables on a schedule.</li>
<li>Delete Storage Blob Containers on a schedule.</li>
</ul>
Additional features will be added in time.<br />
<br />
You can see the GitHub project here: <a href="https://github.com/StealFocus/Forecast">https://github.com/StealFocus/Forecast</a><br />
<div>
<br /></div>
An example configuration is as follows:<br />
<br />
<br />
<pre style="background-color: white; font-family: Consolas; font-size: 13px;"><span style="color: blue;"> <</span><span style="color: #a31515;">stealFocusForecastConfiguration</span><span style="color: blue;"> </span>
<span style="color: blue;"> </span><span style="color: red;">xmlns</span><span style="color: blue;">=</span>"<span style="color: blue;">urn:StealFocus.Forecast.Configuration</span>"<span style="color: blue;">></span></pre>
<pre style="background-color: white; font-family: Consolas; font-size: 13px;"><span style="color: blue;"> <</span><span style="color: #a31515;">scheduleDefinitions</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">scheduleDefinition</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">MorningOutOfHours</span>"<span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">days</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">day</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Monday</span>"<span style="color: blue;"> </span><span style="color: red;">startTime</span><span style="color: blue;">=</span>"<span style="color: blue;">00:00:00</span>"<span style="color: blue;"> </span><span style="color: red;">endTime</span><span style="color: blue;">=</span>"<span style="color: blue;">07:59:59</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">day</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Tuesday</span>"<span style="color: blue;"> </span><span style="color: red;">startTime</span><span style="color: blue;">=</span>"<span style="color: blue;">00:00:00</span>"<span style="color: blue;"> </span><span style="color: red;">endTime</span><span style="color: blue;">=</span>"<span style="color: blue;">07:59:59</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">day</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Wednesday</span>"<span style="color: blue;"> </span><span style="color: red;">startTime</span><span style="color: blue;">=</span>"<span style="color: blue;">00:00:00</span>"<span style="color: blue;"> </span><span style="color: red;">endTime</span><span style="color: blue;">=</span>"<span style="color: blue;">07:59:59</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">day</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Thursday</span>"<span style="color: blue;"> </span><span style="color: red;">startTime</span><span style="color: blue;">=</span>"<span style="color: blue;">00:00:00</span>"<span style="color: blue;"> </span><span style="color: red;">endTime</span><span style="color: blue;">=</span>"<span style="color: blue;">07:59:59</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">day</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Friday</span>"<span style="color: blue;"> </span><span style="color: red;">startTime</span><span style="color: blue;">=</span>"<span style="color: blue;">00:00:00</span>"<span style="color: blue;"> </span><span style="color: red;">endTime</span><span style="color: blue;">=</span>"<span style="color: blue;">07:59:59</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">days</span><span style="color: blue;">></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">scheduleDefinition</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">scheduleDefinition</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">BusinessHours</span>"<span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">days</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">day</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Monday</span>"<span style="color: blue;"> </span><span style="color: red;">startTime</span><span style="color: blue;">=</span>"<span style="color: blue;">08:00:00</span>"<span style="color: blue;"> </span><span style="color: red;">endTime</span><span style="color: blue;">=</span>"<span style="color: blue;">18:00:00</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">day</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Tuesday</span>"<span style="color: blue;"> </span><span style="color: red;">startTime</span><span style="color: blue;">=</span>"<span style="color: blue;">08:00:00</span>"<span style="color: blue;"> </span><span style="color: red;">endTime</span><span style="color: blue;">=</span>"<span style="color: blue;">18:00:00</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">day</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Wednesday</span>"<span style="color: blue;"> </span><span style="color: red;">startTime</span><span style="color: blue;">=</span>"<span style="color: blue;">08:00:00</span>"<span style="color: blue;"> </span><span style="color: red;">endTime</span><span style="color: blue;">=</span>"<span style="color: blue;">18:00:00</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">day</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Thursday</span>"<span style="color: blue;"> </span><span style="color: red;">startTime</span><span style="color: blue;">=</span>"<span style="color: blue;">08:00:00</span>"<span style="color: blue;"> </span><span style="color: red;">endTime</span><span style="color: blue;">=</span>"<span style="color: blue;">18:00:00</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">day</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Friday</span>"<span style="color: blue;"> </span><span style="color: red;">startTime</span><span style="color: blue;">=</span>"<span style="color: blue;">08:00:00</span>"<span style="color: blue;"> </span><span style="color: red;">endTime</span><span style="color: blue;">=</span>"<span style="color: blue;">18:00:00</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">days</span><span style="color: blue;">></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">scheduleDefinition</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">scheduleDefinition</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">EveningOutOfHours</span>"<span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">days</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">day</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Monday</span>"<span style="color: blue;"> </span><span style="color: red;">startTime</span><span style="color: blue;">=</span>"<span style="color: blue;">18:00:01</span>"<span style="color: blue;"> </span><span style="color: red;">endTime</span><span style="color: blue;">=</span>"<span style="color: blue;">23:59:59</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">day</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Tuesday</span>"<span style="color: blue;"> </span><span style="color: red;">startTime</span><span style="color: blue;">=</span>"<span style="color: blue;">18:00:01</span>"<span style="color: blue;"> </span><span style="color: red;">endTime</span><span style="color: blue;">=</span>"<span style="color: blue;">23:59:59</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">day</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Wednesday</span>"<span style="color: blue;"> </span><span style="color: red;">startTime</span><span style="color: blue;">=</span>"<span style="color: blue;">18:00:01</span>"<span style="color: blue;"> </span><span style="color: red;">endTime</span><span style="color: blue;">=</span>"<span style="color: blue;">23:59:59</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">day</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Thursday</span>"<span style="color: blue;"> </span><span style="color: red;">startTime</span><span style="color: blue;">=</span>"<span style="color: blue;">18:00:01</span>"<span style="color: blue;"> </span><span style="color: red;">endTime</span><span style="color: blue;">=</span>"<span style="color: blue;">23:59:59</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">day</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Friday</span>"<span style="color: blue;"> </span><span style="color: red;">startTime</span><span style="color: blue;">=</span>"<span style="color: blue;">18:00:01</span>"<span style="color: blue;"> </span><span style="color: red;">endTime</span><span style="color: blue;">=</span>"<span style="color: blue;">23:59:59</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">days</span><span style="color: blue;">></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">scheduleDefinition</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">scheduleDefinition</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Weekend</span>"<span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">days</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">day</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Saturday</span>"<span style="color: blue;"> </span><span style="color: red;">startTime</span><span style="color: blue;">=</span>"<span style="color: blue;">00:00:00</span>"<span style="color: blue;"> </span><span style="color: red;">endTime</span><span style="color: blue;">=</span>"<span style="color: blue;">23:59:59</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">day</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Sunday</span>"<span style="color: blue;"> </span><span style="color: red;">startTime</span><span style="color: blue;">=</span>"<span style="color: blue;">00:00:00</span>"<span style="color: blue;"> </span><span style="color: red;">endTime</span><span style="color: blue;">=</span>"<span style="color: blue;">23:59:59</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">days</span><span style="color: blue;">></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">scheduleDefinition</span><span style="color: blue;">></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">scheduleDefinitions</span><span style="color: blue;">></span></pre>
<pre style="background-color: white; font-family: Consolas; font-size: 13px;"><span style="color: blue;"> <</span><span style="color: #a31515;">windowsAzure</span><span style="color: blue;">></span></pre>
<pre style="background-color: white; font-family: Consolas; font-size: 13px;"><span style="color: blue;"> <</span><span style="color: #a31515;">subscriptions</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">subscription</span>
<span style="color: blue;"> </span><span style="color: red;">id</span><span style="color: blue;">=</span>"<span style="color: blue;">myArbitraryAzureSubscriptionName</span>"
<span style="color: blue;"> </span><span style="color: red;">subscriptionId</span><span style="color: blue;">=</span>"<span style="color: blue;">GUID</span>"
<span style="color: blue;"> </span><span style="color: red;">certificateThumbprint</span><span style="color: blue;">=</span>"<span style="color: blue;">0000000000000000000000000000000000000000</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">subscriptions</span><span style="color: blue;">></span></pre>
<pre style="background-color: white; font-family: Consolas; font-size: 13px;"><span style="color: blue;"> <</span><span style="color: #a31515;">hostedService</span><span style="color: blue;">></span></pre>
<pre style="background-color: white; font-family: Consolas; font-size: 13px;"><span style="color: blue;"> <</span><span style="color: #a31515;">packages</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">package</span>
<span style="color: blue;"> </span><span style="color: red;">id</span><span style="color: blue;">=</span>"<span style="color: blue;">myArbitraryPackageName</span>"
<span style="color: blue;"> </span><span style="color: red;">storageAccountName</span><span style="color: blue;">=</span>"<span style="color: blue;">myAzureStorageAccountName</span>"
<span style="color: blue;"> </span><span style="color: red;">containerName</span><span style="color: blue;">=</span>"<span style="color: blue;">MyContainer</span>"
<span style="color: blue;"> </span><span style="color: red;">blobName</span><span style="color: blue;">=</span>"<span style="color: blue;">MyPackage.cspkg</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">packages</span><span style="color: blue;">></span></pre>
<pre style="background-color: white; font-family: Consolas; font-size: 13px;"><span style="color: blue;"> <</span><span style="color: #a31515;">deploymentDeletes</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">deploymentDelete</span>
<span style="color: blue;"> </span><span style="color: red;">serviceName</span><span style="color: blue;">=</span>"<span style="color: blue;">myAzureServiceName</span>"
<span style="color: blue;"> </span><span style="color: red;">pollingIntervalInMinutes</span><span style="color: blue;">=</span>"<span style="color: blue;">10</span>"
<span style="color: blue;"> </span><span style="color: red;">subscriptionConfigurationId</span><span style="color: blue;">=</span>"<span style="color: blue;">myArbitraryAzureSubscriptionName</span>"<span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">deploymentSlots</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">deploymentSlot</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Staging</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">deploymentSlot</span><span style="color: blue;"> </span><span style="color: red;">name</span><span style="color: blue;">=</span>"<span style="color: blue;">Production</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">deploymentSlots</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">schedules</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">schedule</span><span style="color: blue;"> </span><span style="color: red;">scheduleDefinitionName</span><span style="color: blue;">=</span>"<span style="color: blue;">MorningOutOfHours</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">schedule</span><span style="color: blue;"> </span><span style="color: red;">scheduleDefinitionName</span><span style="color: blue;">=</span>"<span style="color: blue;">EveningOutOfHours</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">schedule</span><span style="color: blue;"> </span><span style="color: red;">scheduleDefinitionName</span><span style="color: blue;">=</span>"<span style="color: blue;">Weekend</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">schedules</span><span style="color: blue;">></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">deploymentDelete</span><span style="color: blue;">></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">deploymentDeletes</span><span style="color: blue;">></span></pre>
<pre style="background-color: white; font-family: Consolas; font-size: 13px;"><span style="color: blue;"> <</span><span style="color: #a31515;">deploymentCreates</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">deploymentCreate</span>
<span style="color: blue;"> </span><span style="color: red;">subscriptionConfigurationId</span><span style="color: blue;">=</span>"<span style="color: blue;">myArbitraryAzureSubscriptionName</span>"
<span style="color: blue;"> </span><span style="color: red;">windowsAzurePackageId</span><span style="color: blue;">=</span>"<span style="color: blue;">myArbitraryPackageName</span>"
<span style="color: blue;"> </span><span style="color: red;">serviceName</span><span style="color: blue;">=</span>"<span style="color: blue;">myAzureServiceName</span>"
<span style="color: blue;"> </span><span style="color: red;">deploymentName</span><span style="color: blue;">=</span>"<span style="color: blue;">MyName</span>"
<span style="color: blue;"> </span><span style="color: red;">deploymentLabel</span><span style="color: blue;">=</span>"<span style="color: blue;">MyLabel</span>"
<span style="color: blue;"> </span><span style="color: red;">deploymentSlot</span><span style="color: blue;">=</span>"<span style="color: blue;">Production</span>"
<span style="color: blue;"> </span><span style="color: red;">packageConfigurationFilePath</span><span style="color: blue;">=</span>"<span style="color: blue;">C:\PathTo\MyPackageConfiguration.cscfg</span>"
<span style="color: blue;"> </span><span style="color: red;">treatWarningsAsError</span><span style="color: blue;">=</span>"<span style="color: blue;">true</span>"
<span style="color: blue;"> </span><span style="color: red;">startDeployment</span><span style="color: blue;">=</span>"<span style="color: blue;">true</span>"
<span style="color: blue;"> </span><span style="color: red;">pollingIntervalInMinutes</span><span style="color: blue;">=</span>"<span style="color: blue;">10</span>"<span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">schedules</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">schedule</span><span style="color: blue;"> </span><span style="color: red;">scheduleDefinitionName</span><span style="color: blue;">=</span>"<span style="color: blue;">BusinessHours</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">schedules</span><span style="color: blue;">></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">deploymentCreate</span><span style="color: blue;">></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">deploymentCreates</span><span style="color: blue;">></span></pre>
<pre style="background-color: white; font-family: Consolas; font-size: 13px;"><span style="color: blue;"> </</span><span style="color: #a31515;">hostedService</span><span style="color: blue;">></span></pre>
<pre style="background-color: white; font-family: Consolas; font-size: 13px;"><span style="color: blue;"> <</span><span style="color: #a31515;">storageService</span><span style="color: blue;">></span></pre>
<pre style="background-color: white; font-family: Consolas; font-size: 13px;"><span style="color: blue;"> <</span><span style="color: #a31515;">storageAccounts</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">storageAccount</span>
<span style="color: blue;"> </span><span style="color: red;">storageAccountName</span><span style="color: blue;">=</span>"<span style="color: blue;">myStorageAccountName</span>"
<span style="color: blue;"> </span><span style="color: red;">storageAccountKey</span><span style="color: blue;">=</span>"<span style="color: blue;">myStorageAccountKey</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">storageAccounts</span><span style="color: blue;">></span></pre>
<pre style="background-color: white; font-family: Consolas; font-size: 13px;"><span style="color: blue;"> <</span><span style="color: #a31515;">tableDeletes</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">tableDelete</span>
<span style="color: blue;"> </span><span style="color: red;">id</span><span style="color: blue;">=</span>"<span style="color: blue;">myArbitraryTableDeleteId</span>"
<span style="color: blue;"> </span><span style="color: red;">storageAccountName</span><span style="color: blue;">=</span>"<span style="color: blue;">myStorageAccountName</span>"
<span style="color: blue;"> </span><span style="color: red;">pollingIntervalInMinutes</span><span style="color: blue;">=</span>"<span style="color: blue;">60</span>"<span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">storageTables</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">storageTable</span><span style="color: blue;"> </span><span style="color: red;">tableName</span><span style="color: blue;">=</span>"<span style="color: blue;">myAzureTableName1</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">storageTable</span><span style="color: blue;"> </span><span style="color: red;">tableName</span><span style="color: blue;">=</span>"<span style="color: blue;">myAzureTableName2</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">storageTables</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">schedules</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">schedule</span><span style="color: blue;"> </span><span style="color: red;">scheduleDefinitionName</span><span style="color: blue;">=</span>"<span style="color: blue;">MorningOutOfHours</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">schedule</span><span style="color: blue;"> </span><span style="color: red;">scheduleDefinitionName</span><span style="color: blue;">=</span>"<span style="color: blue;">EveningOutOfHours</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">schedule</span><span style="color: blue;"> </span><span style="color: red;">scheduleDefinitionName</span><span style="color: blue;">=</span>"<span style="color: blue;">Weekend</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">schedules</span><span style="color: blue;">></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">tableDelete</span><span style="color: blue;">></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">tableDeletes</span><span style="color: blue;">></span></pre>
<pre style="background-color: white; font-family: Consolas; font-size: 13px;"><span style="color: blue;"> <</span><span style="color: #a31515;">blobContainerDeletes</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">blobContainerDelete</span>
<span style="color: blue;"> </span><span style="color: red;">id</span><span style="color: blue;">=</span>"<span style="color: blue;">myArbitraryBlobContainerDeleteId</span>"
<span style="color: blue;"> </span><span style="color: red;">storageAccountName</span><span style="color: blue;">=</span>"<span style="color: blue;">myStorageAccountName</span>"
<span style="color: blue;"> </span><span style="color: red;">pollingIntervalInMinutes</span><span style="color: blue;">=</span>"<span style="color: blue;">60</span>"<span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">blobContainers</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">blobContainer</span><span style="color: blue;"> </span><span style="color: red;">blobContainerName</span><span style="color: blue;">=</span>"<span style="color: blue;">myAzureBlobContainerName1</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">blobContainer</span><span style="color: blue;"> </span><span style="color: red;">blobContainerName</span><span style="color: blue;">=</span>"<span style="color: blue;">myAzureBlobContainerName2</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">blobContainers</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">schedules</span><span style="color: blue;">></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">schedule</span><span style="color: blue;"> </span><span style="color: red;">scheduleDefinitionName</span><span style="color: blue;">=</span>"<span style="color: blue;">MorningOutOfHours</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">schedule</span><span style="color: blue;"> </span><span style="color: red;">scheduleDefinitionName</span><span style="color: blue;">=</span>"<span style="color: blue;">EveningOutOfHours</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> <</span><span style="color: #a31515;">schedule</span><span style="color: blue;"> </span><span style="color: red;">scheduleDefinitionName</span><span style="color: blue;">=</span>"<span style="color: blue;">Weekend</span>"<span style="color: blue;"> /></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">schedules</span><span style="color: blue;">></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">blobContainerDelete</span><span style="color: blue;">></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">blobContainerDeletes</span><span style="color: blue;">></span></pre>
<pre style="background-color: white; font-family: Consolas; font-size: 13px;"><span style="color: blue;"> </</span><span style="color: #a31515;">storageService</span><span style="color: blue;">></span></pre>
<pre style="background-color: white; font-family: Consolas; font-size: 13px;"><span style="color: blue;"> </</span><span style="color: #a31515;">windowsAzure</span><span style="color: blue;">></span>
<span style="color: blue;"> </</span><span style="color: #a31515;">stealFocusForecastConfiguration</span><span style="color: blue;">></span></pre>
<br />Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-88322752240919565922012-12-03T20:00:00.000+00:002012-12-03T20:00:00.891+00:00Amazon Web Services<br />
“<i>Every day this year, on average, AWS added the same server capacity to its public cloud as it took to run the Amazon.com retail business back in 2003, when it had $5.2bn in revenues. Amazon had "a whole lot of servers" back then in 2003…</i><br />
<i><br /></i>
<i>This time last year, AWS execs were bragging that the public cloud, on average through 2011, was adding enough server capacity each day to run Amazon.com when it was a $2.76bn business in 2000</i>.” - <a href="http://www.theregister.co.uk/2012/11/29/amazon_aws_update_jassy/">http://www.theregister.co.uk/2012/11/29/amazon_aws_update_jassy/</a><br />
<br />
Wow.<br />
Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-9594549364152119762012-11-26T20:00:00.000+00:002012-11-26T20:00:06.858+00:00IDisposable and object initialisersBackground...<br />
<br />
The "using" statement is just syntax trick. The resulting compiled code from a "using" statement is actually a try-catch statement.<br />
<br />
This...<br />
<br />
<br />
<pre style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">MyClass</span>
{
<span style="color: blue;">public</span> <span style="color: blue;">void</span> MyMethod()
{
<span style="color: blue;">using</span> (<span style="color: #2b91af;">MyDisposableClass</span> myDisposableClass = <span style="color: blue;">new</span> <span style="color: #2b91af;">MyDisposableClass</span>())
{
myDisposableClass.DoSomething();
}
}
}</pre>
<br />
<br />
...is converted by the compiler to this...<br />
<br />
<br />
<pre style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">MyClass</span>
{
<span style="color: blue;">public</span> <span style="color: blue;">void</span> MyMethod2()
{
<span style="color: #2b91af;">MyDisposableClass</span> myDisposableClass = <span style="color: blue;">null</span>;
<span style="color: blue;">try</span>
{
myDisposableClass = <span style="color: blue;">new</span> <span style="color: #2b91af;">MyDisposableClass</span>();
}
<span style="color: blue;">catch</span>
{
myDisposableClass.Dispose();
}
}
}</pre>
<br />
<br />
Problem...<br />
<br />
Consider the following code:<br />
<br />
<pre style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">MyClass</span>
{
<span style="color: blue;">public</span> <span style="color: blue;">void</span> MyMethod()
{
<span style="color: blue;">using</span> (<span style="color: #2b91af;">MyDisposableClass</span> myDisposableClass = <span style="color: blue;">new</span> <span style="color: #2b91af;">MyDisposableClass</span>
{
MyProperty = <span style="color: blue;">string</span>.Empty
})
{
myDisposableClass.DoSomething();
}
}
}</pre>
<br />
<br />
This can cause a problem.<br />
<br />
The problem is caused by the object initialiser. Remember, the object initialiser is just syntactic sugar. "Under the covers" (the actual compiled code), the object will be created as normal with its constructor and then the properties would be assigned afterwards.<br />
<br />
So the use of the object initialiser means the object will be created outside the scope of the using statement. This in turn means the scope of the try-catch statement generated by the compiler would be incorrect. If the object is not created inside the scope of the using statement (and therefore the try-catch statement), should there be an error during the creation and initialisation, then "Dispose" will never be called. If Dispose is never called, the object will not be disposed in a timely manner. This means you may leak resources.<br />
<br />
FxCop will advise you of the problem with an error like the following:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">CA2000 : Microsoft.Reliability : In method 'MyClass.MyMethod()', object '<>g__initLocal0' is not disposed along all exception paths. Call System.IDisposable.Dispose on object '<>g__initLocal0' before all references to it are out of scope.</span><br />
<br />
The correct code is as follows:<br />
<br />
<br />
<pre style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">MyClass</span>
{
<span style="color: blue;">public</span> <span style="color: blue;">void</span> MyMethod()
{
<span style="color: blue;">using</span> (<span style="color: #2b91af;">MyDisposableClass</span> myDisposableClass = <span style="color: blue;">new</span> <span style="color: #2b91af;">MyDisposableClass</span>())
{
myDisposableClass.MyProperty = <span style="color: blue;">string</span>.Empty;
myDisposableClass.DoSomething();
}
}
}</pre>
<br />
<br />
The lesson is not to use object initialisers in combination with "using" statements.Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-68103195882197893502012-11-19T20:00:00.000+00:002012-11-19T20:00:05.351+00:00Enterprise debtFollowing on from the <a href="http://callumhibbert.blogspot.co.uk/2012/11/technical-debt.html" target="_blank">earlier post</a> on Technical Debt, there exists a similar concept for the enterprise - "Enterprise Debt".<br />
<br />
Enterprise debt follows the exact same parallels with financial debt. You may have inefficient business processes, duplicated business processes, manual processes or a myriad of problems with your Enterprise Architecture. These problems constitute a tax on your business but this costs may be justified. Duplicated business processes might allow different business units to start or move in parallel. Inefficient or manual business process might be justified because you have not had time to improve them or automated them, yet they perform a critical function. You might be happy, in the short or medium term, to pay the interest on these debts to keep your enterprise functioning.<br />
<br />
Of course, as before, you must take care not to go bankrupt. Should your enterprise debt exceed your capacity to pay down the interest, your business is finished.<br />
<br />
One of the goals of an Enterprise Architecture initiative should be to identify your enterprise debt and seek to reduce it. An ongoing Enterprise Architecture program should also identify new enterprise debt and ensure that it is justified i.e. the "tax" that it incurs brings a larger long term benefit.Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-12974863973728373032012-11-12T20:00:00.000+00:002012-11-12T20:00:03.443+00:00Technical debtTechnical debt is a way of describing some of the costs you can incur when building software. For example, when implementing a feature in a system you generally have two options.<br />
<br />
<ol>
<li>Implement the feature quickly, knowing that it will make future changes to the system harder.</li>
<li>Implement the feature with more care (using time/effort) resulting in a better design and more robust implementation. This makes subsequent changes to the system easier.</li>
</ol>
<div>
There is a clear trade off here. You can liken technical debt to financial debt.</div>
<div>
<br /></div>
<div>
When incurring technical debt, as with financial debt, you will have to pay "interest". In the example above, the interest you pay on quickly implementing the feature is the additional cost required to implement subsequent features. You can continue to pay the interest each time you add a feature or you can repay the principal by going back and implementing the original feature properly.</div>
<div>
<br /></div>
<div>
Note that technical debt, like financial debt, is sometimes useful. In the same way that you likely couldn't buy a house without going into debt, sometimes you might struggle to deliver an application or system without taking on some technical debt first. Examples of useful technical debt are as follows...</div>
<div>
<ul>
<li>Quickly building features so that users or business sponsors can see functionality.</li>
<li>Quickly building features to attract more customers or satisfy existing ones.</li>
<li>Quickly building features (or a whole product!) so that you get first mover advantage over competitors.</li>
</ul>
</div>
<div>
In most circumstances the driver for taking on technical debt is time, for example, you have to deliver the software on a certain date.</div>
<div>
<br /></div>
<div>
However, like with financial debt, you must take care not to go bankrupt. Should the interest payments exceed your capacity to repay them, you are finished.</div>
<div>
<br /></div>
<div>
Should you be spending all your effort on simply paying down the interest on your debts, you will be unable to move your project or business forward. At this point your your project or business will fail.</div>
<div>
<br /></div>
<div>
There are many examples of technical debt. Not having an automated deployment mechanism is common. Not having such a thing saves you the time it takes to implement one. The trade off being that this costs you time/effort for each occasion you deploy your application, because you have to do the deployment manually. You can either invest the time to implement an automated deployment and then experience very low cost for subsequent deployments or continue with a fixed cost for each release. Note that if the application has a short lifespan, and you will only deploy the application a few times, then it's simply not worth investing in the automated deployment mechanism. Continuing the financial debt parallel, this is similar to renting a car versus buying a car. The automated deployment is like buying the car - large up front cost giving a low cost for subsequent uses. Where as manual deployments are like renting a car - zero up front costs but a fixed cost for each use.</div>
<div>
<br /></div>
<div>
Like most things in software, its a matter of weighing up the costs and benefits. Taking on technical debt can be justified but should be clearly acknowledged if it is. In the vast majority of times there should be a plan to pay off the debt.</div>
Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-51461975991217991162012-11-06T20:00:00.001+00:002012-11-06T20:00:07.443+00:00SignalR included in ASP.NET Fall 2012 UpdateJust what it says on the tin, the SignalR framework is included in ASP.NET Fall 2012 Update.<br />
<div>
<br /></div>
<div>
<a href="http://weblogs.asp.net/jgalloway/archive/2012/10/31/ten-oh-wait-eleven-eleven-things-you-should-know-about-the-asp-net-fall-2012-update.aspx">http://weblogs.asp.net/jgalloway/archive/2012/10/31/ten-oh-wait-eleven-eleven-things-you-should-know-about-the-asp-net-fall-2012-update.aspx</a></div>
<div>
<br /></div>
<div>
It's really great to see Microsoft really embracing open source components, giving them first class support (SignalR Hub Classes have their own Visual Studio templates) and delivering them via NuGet.<br />
<br />
And if you've not yet heard of SignalR, you really need to check it out.</div>
Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-59928662620520309862012-11-05T20:00:00.000+00:002012-11-05T20:00:02.758+00:00Base 64 encoding stringsEncoding strings to base 64 is super trivial...<br />
<br />
The code.<br />
<br />
<br />
<pre style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;"> <span style="color: blue;">using</span> System;
<span style="color: blue;">using</span> System.Text;
<span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">StringExtensions</span>
{
<span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">string</span> Base64Encode(<span style="color: blue;">this</span> <span style="color: blue;">string</span> text)
{
<span style="color: blue;">byte</span>[] bytes = <span style="color: blue;">new</span> <span style="color: #2b91af;">UTF8Encoding</span>().GetBytes(text);
<span style="color: blue;">string</span> base64EncodedText = <span style="color: #2b91af;">Convert</span>.ToBase64String(bytes);
<span style="color: blue;">return</span> base64EncodedText;
}
<span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">string</span> Base64Decode(<span style="color: blue;">this</span> <span style="color: blue;">string</span> base64EncodedText)
{
<span style="color: blue;">byte</span>[] bytes = <span style="color: #2b91af;">Convert</span>.FromBase64String(base64EncodedText);
<span style="color: blue;">string</span> text = <span style="color: blue;">new</span> <span style="color: #2b91af;">UTF8Encoding</span>().GetString(bytes);
<span style="color: blue;">return</span> text;
}
}</pre>
<br />
<br />
The test.<br />
<br />
<br />
<pre style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;"> <span style="color: blue;">using</span> Microsoft.VisualStudio.TestTools.UnitTesting;
[<span style="color: #2b91af;">TestClass</span>]
<span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">StringExtensionsTests</span>
{
[<span style="color: #2b91af;">TestMethod</span>]
<span style="color: blue;">public</span> <span style="color: blue;">void</span> TestEncodeAndDecode()
{
<span style="color: blue;">const</span> <span style="color: blue;">string</span> OrginalText = <span style="color: #a31515;">"originalText"</span>;
<span style="color: blue;">string</span> encodedText = OrginalText.Base64Encode();
<span style="color: #2b91af;">Assert</span>.AreNotEqual(OrginalText, encodedText, <span style="color: #a31515;">"The encoded text was the same as the original plain text."</span>);
<span style="color: blue;">string</span> decodedText = encodedText.Base64Decode();
<span style="color: #2b91af;">Assert</span>.AreEqual(OrginalText, decodedText, <span style="color: #a31515;">"The decoded text was not the same as the original plain text."</span>);
}
}</pre>
<br />
<br />
And that is it.<br />
<br />
Not sure why there aren't such methods in the Base Class Libraries (BCL).Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-31435085078081644092012-11-02T20:00:00.000+00:002012-11-02T20:00:03.511+00:00Interrogating NServiceBus Saga data stored in RavenDBThese days, NServiceBus stores its data in RavenDB, including any saga data. Sometimes it is useful to interrogate the saga data to report on running processes.<div>
<br /></div>
<div>
Querying the saga data stored in NServiceBus is not as simple as plain RavenDB Document Store client, you need to supply conventions to be able to pick up the saga data.</div>
<div>
<br /></div>
<div>
An example is as follows:</div>
<div>
<br /></div>
<div>
<pre style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;"> <span style="color: blue;">using</span> System;
<span style="color: blue;">using</span> System.Linq;
<span style="color: blue;">using</span> NServiceBus.Persistence.Raven;
<span style="color: blue;">using</span> Raven.Client;
<span style="color: blue;">using</span> Raven.Client.Document;
<span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Example</span>
{
<span style="color: blue;">public</span> <span style="color: blue;">void</span> GetSagaDataFromRavenDB()
{
<span style="color: blue;">using</span> (<span style="color: #2b91af;">IDocumentStore</span> documentStore = <span style="color: blue;">new</span> <span style="color: #2b91af;">DocumentStore</span>
{
ConnectionStringName = <span style="color: #a31515;">"MyConnectionString"</span>,
ResourceManagerId = <span style="color: #2b91af;">Guid</span>.Parse(<span style="color: #a31515;">"C6687DB2-764C-46A4-A3C5-15A3BA22A01A"</span>),
Conventions = <span style="color: blue;">new</span> <span style="color: #2b91af;">DocumentConvention</span>
{
FindTypeTagName = <span style="color: blue;">new</span> <span style="color: #2b91af;">RavenConventions</span>().FindTypeTagName
}
})
{
documentStore.Initialize();
<span style="color: blue;">using</span> (<span style="color: #2b91af;">IDocumentSession</span> documentSession = documentStore.OpenSession())
{
<span style="color: #2b91af;">MySagaData</span>[] mySagaDatas =
(<span style="color: blue;">from</span> mySagaData <span style="color: blue;">in</span> documentSession.Query<<span style="color: #2b91af;">MySagaData</span>>()
<span style="color: blue;">select</span> mySagaData).ToArray();
<span style="color: blue;">foreach</span> (<span style="color: #2b91af;">MySagaData</span> mySagaData <span style="color: blue;">in</span> mySagaDatas)
{
<span style="color: #2b91af;">Console</span>.WriteLine(mySagaData.SomeProperty);
}
}
}
}
}</pre>
</div>
<div>
<br /></div>
<div>
The GUID is specific (you need to supply that one) and the "RavenConventions" come from the NServiceBus persistence API.</div>
<div>
<br /></div>
<div>
And that is it.</div>
Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-90733945428590943452012-10-30T20:00:00.000+00:002012-10-30T23:14:37.743+00:00Windows Azure Storage URLsFollowing on from the <a href="http://callumhibbert.blogspot.co.uk/2012/10/access-to-windows-azure-storage-emulator.html" target="_blank">previous post</a> about accessing the Azure Storage Emulator, you would also need to know what the actual endpoint URLs are.<br />
<br />
<br />
The following URL formats are used for addressing resources running on Azure and on the storage emulator:<br />
<h4>
Blob Service</h4>
Emulator - http://127.0.0.1:10000/storageaccount/<br />
Azure - http://storageaccount.blob.core.windows.net/<br />
<h4>
Queue Service</h4>
Emulator - http://127.0.0.1:10001/storageaccount/<br />
Azure - http://storageaccount.queue.core.windows.net/<br />
<h4>
Table Service</h4>
Emulator - http://127.0.0.1:10002/storageaccount/<br />
Azure - http://storageaccount.table.core.windows.net/<br />
<br />
For your emulator, the "storageaccount" is always "devstoreaccount1".<br />
<br />
The "storageaccount" value for Azure is whatever you created. The name is always lowercase and cannot contain spaces or special characters.Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-89146355731090706162012-10-29T20:00:00.000+00:002012-10-29T20:00:02.432+00:00Access to the Windows Azure Storage EmulatorShould you wish to do any work against the Windows Azure Storage Emulator, say testing the REST API, you might be wondering what the account name and account key might be.<br />
<br />
Those details for the Storage Emulator are the same for every single installation of the developer tools, they do not vary between machines.<br />
<br />
They are published here: <a href="http://msdn.microsoft.com/en-us/library/windowsazure/gg432983.aspx">http://msdn.microsoft.com/en-us/library/windowsazure/gg432983.aspx</a><br />
<br />
Account name:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">devstoreaccount1</span><br />
<br />
Account key:<br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span>
<span style="font-family: 'Courier New', Courier, monospace;">Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==</span><br />
<br />
Giving you a connection string of:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">DefaultEndpointsProtocol=https;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==</span><br />
<br />
Though the following is also a valid connection string for the Storage Emulator:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">usedevelopmentstorage=true</span><br />
<br />
The individual account name and key would be of use when you don't have a connection string, like the aforementioned REST API.Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-48961177130353239882012-10-26T20:00:00.000+01:002012-10-26T20:00:04.408+01:00A "processing" dialogue box with jQuerySuppose you want to create something like the following:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtvXrHjwrvLLBtNKNk23dfsUmwQjmRNkHEB8lT6v2zjMY9aggeuDYGbH4ku7scncAL5B9w58LWuJpW2oIIaRlVXDWpgXtfnyPbc39hzJQM7QpMjcUZhElJcvVYPKpj2u0uvb7R486ZAtQ/s1600/Processing.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="237" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtvXrHjwrvLLBtNKNk23dfsUmwQjmRNkHEB8lT6v2zjMY9aggeuDYGbH4ku7scncAL5B9w58LWuJpW2oIIaRlVXDWpgXtfnyPbc39hzJQM7QpMjcUZhElJcvVYPKpj2u0uvb7R486ZAtQ/s320/Processing.jpg" width="320" /></a></div>
<br />
<br />
Common scenarios are when a user submits something and you want to wait for a response without refreshing the page.<br />
<br />
This is easy!<br />
<br />
First add two NuGet packages to your web application:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;"> install-package jQuery-UI</span><br />
<span style="font-family: Courier New, Courier, monospace;"> install-package jQuery.UI.Combined</span><br />
<br />
Then use the following mark-up:<br />
<br />
<br />
<pre style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;"><span style="color: blue;"><!</span><span style="color: maroon;">DOCTYPE</span> <span style="color: red;">html</span> <span style="color: red;">PUBLIC</span> <span style="color: blue;">"-//W3C//DTD XHTML 1.0 Transitional//EN"</span> <span style="color: blue;">"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">html</span> <span style="color: red;">xmlns</span><span style="color: blue;">=</span><span style="color: blue;">"http://www.w3.org/1999/xhtml"</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">head</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">title</span><span style="color: blue;">></</span><span style="color: maroon;">title</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">=</span><span style="color: blue;">"Content/themes/base/jquery-ui.css"</span> <span style="color: red;">rel</span><span style="color: blue;">=</span><span style="color: blue;">"stylesheet"</span> <span style="color: red;">type</span><span style="color: blue;">=</span><span style="color: blue;">"text/css"</span> <span style="color: blue;">/></span>
<span style="color: blue;"><</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">=</span><span style="color: blue;">"Content/themes/base/jquery.ui.core.css"</span> <span style="color: red;">rel</span><span style="color: blue;">=</span><span style="color: blue;">"stylesheet"</span> <span style="color: red;">type</span><span style="color: blue;">=</span><span style="color: blue;">"text/css"</span> <span style="color: blue;">/></span>
<span style="color: blue;"><</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">=</span><span style="color: blue;">"Content/themes/base/jquery.ui.theme.css"</span> <span style="color: red;">rel</span><span style="color: blue;">=</span><span style="color: blue;">"stylesheet"</span> <span style="color: red;">type</span><span style="color: blue;">=</span><span style="color: blue;">"text/css"</span> <span style="color: blue;">/></span>
<span style="color: blue;"><</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">=</span><span style="color: blue;">"Content/themes/base/jquery.ui.dialog.css"</span> <span style="color: red;">rel</span><span style="color: blue;">=</span><span style="color: blue;">"stylesheet"</span> <span style="color: red;">type</span><span style="color: blue;">=</span><span style="color: blue;">"text/css"</span> <span style="color: blue;">/></span>
<span style="color: blue;"><</span><span style="color: maroon;">script</span> <span style="color: red;">src</span><span style="color: blue;">=</span><span style="color: blue;">"Scripts/jquery-1.8.2.js"</span> <span style="color: red;">type</span><span style="color: blue;">=</span><span style="color: blue;">"text/javascript"</span><span style="color: blue;">></</span><span style="color: maroon;">script</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">script</span> <span style="color: red;">src</span><span style="color: blue;">=</span><span style="color: blue;">"Scripts/jquery-ui-1.9.0.js"</span> <span style="color: red;">type</span><span style="color: blue;">=</span><span style="color: blue;">"text/javascript"</span><span style="color: blue;">></</span><span style="color: maroon;">script</span><span style="color: blue;">></span>
<span style="color: blue;"></</span><span style="color: maroon;">head</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">body</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">script</span> <span style="color: red;">type</span><span style="color: blue;">=</span><span style="color: blue;">"text/javascript"</span><span style="color: blue;">></span>
$(document).ready(<span style="color: blue;">function</span> () {
$(<span style="color: maroon;">"#progressDialog"</span>).dialog({
autoOpen: <span style="color: blue;">false</span>,
draggable: <span style="color: blue;">false</span>,
modal: <span style="color: blue;">true</span>,
resizable: <span style="color: blue;">false</span>,
closeOnEscape: <span style="color: blue;">false</span>,
open: progressDialogOpen
});
});
<span style="color: blue;">function</span> progressDialogOpen() {
$(<span style="color: maroon;">".ui-dialog-titlebar-close"</span>, <span style="color: blue;">this</span>.parentNode).hide();
}
<span style="color: blue;">function</span> progressDialogClose() {
$(<span style="color: maroon;">"#progressDialog"</span>).dialog(<span style="color: maroon;">'close'</span>);
}
<span style="color: blue;">function</span> doSomethingOpen() {
$(<span style="color: maroon;">"#progressDialog"</span>).dialog(<span style="color: maroon;">'open'</span>);
setTimeout(progressDialogClose, 3000);
<span style="color: blue;">return</span> <span style="color: blue;">false</span>;
}
<span style="color: blue;">function</span> doSomethingClose() {
progressDialogClose();
}
<span style="color: blue;"></</span><span style="color: maroon;">script</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">button</span> <span style="color: red;">onclick</span><span style="color: blue;">=</span><span style="color: blue;">"doSomethingOpen()"</span><span style="color: blue;">></span>Open<span style="color: blue;"></</span><span style="color: maroon;">button</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">button</span> <span style="color: red;">onclick</span><span style="color: blue;">=</span><span style="color: blue;">"doSomethingClose()"</span><span style="color: blue;">></span>Close<span style="color: blue;"></</span><span style="color: maroon;">button</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">id</span><span style="color: blue;">=</span><span style="color: blue;">"progressDialog"</span> <span style="color: red;">title</span><span style="color: blue;">=</span><span style="color: blue;">"Processing"</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">img</span> <span style="color: red;">alt</span><span style="color: blue;">=</span><span style="color: blue;">"Processing..."</span> <span style="color: red;">src</span><span style="color: blue;">=</span><span style="color: blue;">"Content/images/YourAnimatedProcessingImage.gif"</span> <span style="color: blue;">/></span>
<span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span>
<span style="color: blue;"></</span><span style="color: maroon;">body</span><span style="color: blue;">></span>
<span style="color: blue;"></</span><span style="color: maroon;">html</span><span style="color: blue;">></span></pre>
<br />
<br />
Note that this example just puts in a time out to simulate something happening. You can replace the call to "setTimeout" with some server call.<br />
<br />
And that is it.Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-8949193770575128202012-10-25T20:00:00.000+01:002012-10-25T20:00:02.568+01:00Building Windows Services with TopShelf<a href="http://topshelf-project.com/" target="_blank">TopShelf</a> is a framework you can use to build windows services which can be installed easily. It is used by such famous products as <a href="http://nservicebus.com/" target="_blank">NServiceBus</a>. It allows you to create windows services that you don't have to install with "installutil.exe". The windows service you create is self installing.<br />
<br />
When using TopShelf, you install your windows service by running the following command:<br />
<br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">Acme.TopShelfExample.Windows.Service.exe install</span><br />
<br />
Which would result in the following console output:<br />
<br />
<br />
<span style="font-family: Courier New, Courier, monospace;"> Configuration Result:</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">[Success] Name ExampleWorker</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">[Success] DisplayName Example Worker</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">[Success] Description An Example Worker.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">[Success] ServiceName ExampleWorker</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">Topshelf v3.0.105.0, .NET Framework v4.0.30319.269</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">Running a transacted installation.</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">Beginning the Install phase of the installation.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">Installing Example Worker service</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">Installing service ExampleWorker...</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">Service ExampleWorker has been successfully installed.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">Creating EventLog source ExampleWorker in log Application...</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">The Install phase completed successfully, and the Commit phase is beginning.</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">The Commit phase completed successfully.</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">The transacted install has completed.</span><br />
<br />
<br />
Which is pretty much the same as you get using "installutil.exe".<br />
<br />
To uninstall, run the following:<br />
<br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">Acme.TopShelfExample.Windows.Service.exe uninstall</span><br />
<br />
Which would result in the following console output:<br />
<br />
<br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">Configuration Result:</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">[Success] Name ExampleWorker</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">[Success] DisplayName Example Worker</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">[Success] Description An Example Worker.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">[Success] ServiceName ExampleWorker</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">Topshelf v3.0.105.0, .NET Framework v4.0.30319.269</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">The uninstall is beginning.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">Uninstalling ExampleWorker service</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">Removing EventLog source ExampleWorker.</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">Service ExampleWorker is being removed from the system...</span><br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">Service ExampleWorker was successfully removed from the system.</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">The uninstall has completed.</span><br />
<br />
<br />
Again, the same as you'd get using "installutil.exe".<br />
<br />
To use TopShelf for your windows service, create a console application and install TopShelf using NuGet:<br />
<br />
<span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"> </span><span style="font-family: Courier New, Courier, monospace;">install-package TopShelf</span><br />
<br />
The following code should get you started:<br />
<br />
<br />
<pre style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;"><span style="color: blue;">namespace</span> Acme.TopShelfExample.Windows.Service
{
<span style="color: blue;">using</span> Topshelf;
<span style="color: blue;">internal</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Program</span>
{
<span style="color: blue;">internal</span> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)
{
<span style="color: #2b91af;">HostFactory</span>.Run(hostConfigurator =>
{
hostConfigurator.Service<<span style="color: #2b91af;">ExampleWorker</span>>(serviceConfigurator =>
{
serviceConfigurator.ConstructUsing(name => <span style="color: blue;">new</span> <span style="color: #2b91af;">ExampleWorker</span>());
serviceConfigurator.WhenStarted(ew => ew.Start());
serviceConfigurator.WhenStopped(ew =>
{
ew.Stop();
<span style="color: green;">// And dispose or release any component containers (e.g. Castle) </span>
<span style="color: green;">// or items resolved from the container.</span>
});
});
hostConfigurator.RunAsLocalSystem();
hostConfigurator.SetDescription(<span style="color: #a31515;">"An Example Worker."</span>);
hostConfigurator.SetDisplayName(<span style="color: #a31515;">"Example Worker"</span>);
hostConfigurator.SetServiceName(<span style="color: #a31515;">"ExampleWorker"</span>); <span style="color: green;">// No spaces allowed</span>
hostConfigurator.StartAutomatically();
});
}
}
}</pre>
<br />
<br />
<br />
<pre style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;"><span style="color: blue;">namespace</span> Acme.TopShelfExample.Windows.Service
{
<span style="color: blue;">using</span> System;
<span style="color: blue;">using</span> System.Globalization;
<span style="color: blue;">using</span> System.Threading;
<span style="color: blue;">public</span> <span style="color: blue;">abstract</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Worker</span>
{
<span style="color: blue;">private</span> <span style="color: #2b91af;">Thread</span> thread;
<span style="color: blue;">private</span> <span style="color: blue;">bool</span> stop = <span style="color: blue;">true</span>;
<span style="color: blue;">protected</span> Worker()
{
<span style="color: blue;">this</span>.SleepPeriod = <span style="color: blue;">new</span> <span style="color: #2b91af;">TimeSpan</span>(0, 0, 0, 10);
<span style="color: blue;">this</span>.Id = <span style="color: #2b91af;">Guid</span>.NewGuid();
}
<span style="color: blue;">public</span> <span style="color: #2b91af;">TimeSpan</span> SleepPeriod { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
<span style="color: blue;">public</span> <span style="color: blue;">bool</span> IsStopped { <span style="color: blue;">get</span>; <span style="color: blue;">private</span> <span style="color: blue;">set</span>; }
<span style="color: blue;">protected</span> <span style="color: #2b91af;">Guid</span> Id { <span style="color: blue;">get</span>; <span style="color: blue;">private</span> <span style="color: blue;">set</span>; }
<span style="color: blue;">public</span> <span style="color: blue;">void</span> Start()
{
<span style="color: blue;">string</span> logMessage = <span style="color: blue;">string</span>.Format(<span style="color: #2b91af;">CultureInfo</span>.CurrentCulture, <span style="color: #a31515;">"Starting worker of type '</span><span style="color: mediumseagreen;">{0}</span><span style="color: #a31515;">'."</span>, <span style="color: blue;">this</span>.GetType().FullName);
System.Diagnostics.<span style="color: #2b91af;">Debug</span>.WriteLine(logMessage);
<span style="color: blue;">this</span>.stop = <span style="color: blue;">false</span>;
<span style="color: green;">// Multiple thread instances cannot be created</span>
<span style="color: blue;">if</span> (<span style="color: blue;">this</span>.thread == <span style="color: blue;">null</span> || <span style="color: blue;">this</span>.thread.ThreadState == <span style="color: #2b91af;">ThreadState</span>.Stopped)
{
<span style="color: blue;">this</span>.thread = <span style="color: blue;">new</span> <span style="color: #2b91af;">Thread</span>(<span style="color: blue;">this</span>.Run);
}
<span style="color: green;">// Start thread if it's not running yet</span>
<span style="color: blue;">if</span> (<span style="color: blue;">this</span>.thread.ThreadState != <span style="color: #2b91af;">ThreadState</span>.Running)
{
<span style="color: blue;">this</span>.thread.Start();
}
}
<span style="color: blue;">public</span> <span style="color: blue;">void</span> Stop()
{
<span style="color: blue;">string</span> logMessage = <span style="color: blue;">string</span>.Format(<span style="color: #2b91af;">CultureInfo</span>.CurrentCulture, <span style="color: #a31515;">"Stopping worker of type '</span><span style="color: mediumseagreen;">{0}</span><span style="color: #a31515;">'."</span>, <span style="color: blue;">this</span>.GetType().FullName);
System.Diagnostics.<span style="color: #2b91af;">Debug</span>.WriteLine(logMessage);
<span style="color: blue;">this</span>.stop = <span style="color: blue;">true</span>;
}
<span style="color: blue;">protected</span> <span style="color: blue;">abstract</span> <span style="color: blue;">void</span> DoWork();
<span style="color: blue;">private</span> <span style="color: blue;">void</span> Run()
{
<span style="color: blue;">try</span>
{
<span style="color: blue;">try</span>
{
<span style="color: blue;">while</span> (!<span style="color: blue;">this</span>.stop)
{
<span style="color: blue;">this</span>.IsStopped = <span style="color: blue;">false</span>;
<span style="color: blue;">this</span>.DoWork();
<span style="color: #2b91af;">Thread</span>.Sleep(<span style="color: blue;">this</span>.SleepPeriod);
}
}
<span style="color: blue;">catch</span> (<span style="color: #2b91af;">ThreadAbortException</span>)
{
<span style="color: #2b91af;">Thread</span>.ResetAbort();
}
<span style="color: blue;">finally</span>
{
<span style="color: blue;">this</span>.thread = <span style="color: blue;">null</span>;
<span style="color: blue;">this</span>.IsStopped = <span style="color: blue;">true</span>;
<span style="color: blue;">string</span> logMessage = <span style="color: blue;">string</span>.Format(<span style="color: #2b91af;">CultureInfo</span>.CurrentCulture, <span style="color: #a31515;">"Stopped worker of type '</span><span style="color: mediumseagreen;">{0}</span><span style="color: #a31515;">'."</span>, <span style="color: blue;">this</span>.GetType().FullName);
System.Diagnostics.<span style="color: #2b91af;">Debug</span>.WriteLine(logMessage);
}
}
<span style="color: blue;">catch</span> (<span style="color: #2b91af;">Exception</span> e)
{
<span style="color: blue;">string</span> exceptionMessage = <span style="color: blue;">string</span>.Format(<span style="color: #2b91af;">CultureInfo</span>.CurrentCulture, <span style="color: #a31515;">"Error running the '</span><span style="color: mediumseagreen;">{0}</span><span style="color: #a31515;">' worker."</span>, <span style="color: blue;">this</span>.GetType().FullName);
System.Diagnostics.<span style="color: #2b91af;">Debug</span>.WriteLine(exceptionMessage, e);
<span style="color: blue;">throw</span>;
}
}
}
}
</pre>
<br />
<br />
<br />
<pre style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 13px;"><span style="color: blue;">namespace</span> Acme.TopShelfExample.Windows.Service
{
<span style="color: blue;">using</span> System.Diagnostics;
<span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">ExampleWorker</span> : <span style="color: #2b91af;">Worker</span>
{
<span style="color: blue;">protected</span> <span style="color: blue;">override</span> <span style="color: blue;">void</span> DoWork()
{
<span style="color: #2b91af;">Debug</span>.WriteLine(<span style="color: #a31515;">"Example Worker is doing something."</span>);
}
}
}</pre>
<br />
<br />
And that is it.Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-87074384524901595022012-10-24T20:00:00.000+01:002012-10-25T12:51:26.887+01:00Service Bus for Windows ServerMicrosoft have released Service Bus for Windows Server.<br />
<br />
<a href="http://msdn.microsoft.com/en-us/library/windowsazure/jj193022(v=azure.10).aspx">http://msdn.microsoft.com/en-us/library/windowsazure/jj193022(v=azure.10).aspx</a><br />
<br />
This is essentially an on premise equivalent of the Windows Azure Service Bus (not to be confused with Azure Storage Queues). The rumour is that development for MSMQ has stopped and Service Bus is the strategic replacement.<br />
<br />
One other point of note is that this solves one annoying issue when developing with Windows Azure. Pretty much all of the main components to Windows Azure have local "equivalents"...<br />
<br />
<ul>
<li>Local development with Cloud Services is supported by the Compute Emulator.</li>
<li>Local development with Azure Storage (Blobs, Tables, Queues) is supported by the Storage Emulator.</li>
<li>Local development with SQL Azure can be achieved (with care over which features you use) on SQL Server.</li>
</ul>
<div>
...but the Azure Service Bus has never had an answer for local development. Now it does, the Service Bus for Windows Server behaves the same.<br />
<br />
Update: <a href="http://blogs.msdn.com/b/windowsazure/archive/2012/10/24/announcing-public-availability-of-service-bus-for-windows-server-service-bus-1-0.aspx" target="_blank">Blog post from Microsoft</a>.</div>
Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-61345384791124093162012-10-23T20:00:00.000+01:002012-10-23T20:00:06.168+01:00MSBuild code formattingSpeaks for itself...<br />
<br />
<h4>
Bad</h4>
<div style="background-color: white; color: #222222; font-size: 13px;">
<span style="font-family: Courier New, Courier, monospace;"> <Target Name="MyExampleTarget1"></span></div>
<div style="background-color: white; color: #222222; font-size: 13px;">
<span style="font-family: Courier New, Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"><</span><span style="font-family: Courier New, Courier, monospace;">SomeMSBuildTaskThatDoesSomethi<wbr></wbr>ngOrOtherWithALongName SomePropertyForTheTaskWithALon<wbr></wbr>gName="value1" AnotherPropertyForTheTaskWithA<wbr></wbr>LongName="value2" /</span><span style="font-family: 'Courier New', Courier, monospace;">></span></div>
<div style="background-color: white; color: #222222; font-size: 13px;">
<span style="font-family: Courier New, Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"><</span><span style="font-family: Courier New, Courier, monospace;">MSBuildTaskWithShortNameName AProperty="value3" /</span><span style="font-family: 'Courier New', Courier, monospace;">></span></div>
<div style="background-color: white; color: #222222; font-size: 13px;">
<span style="font-family: Courier New, Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"><</span><span style="font-family: Courier New, Courier, monospace;">/Target</span><span style="font-family: 'Courier New', Courier, monospace;">></span></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px;">
The end of the line extends outside the editor window so you can't see the end argument without scolling horizontally.</div>
<h4>
Bad</h4>
<div style="background-color: white; color: #222222; font-size: 13px;">
<span style="font-family: Courier New, Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"><</span><span style="font-family: Courier New, Courier, monospace;">Target Name="MyExampleTarget2"</span><span style="font-family: 'Courier New', Courier, monospace;">></span></div>
<div style="background-color: white; color: #222222; font-size: 13px;">
<span style="font-family: Courier New, Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"><</span><span style="font-family: Courier New, Courier, monospace;">SomeMSBuildTaskThatDoesSomethi<wbr></wbr>ngOrOtherWithALongName SomePropertyForTheTaskWithALon<wbr></wbr>gName="value1" </span></div>
<div style="background-color: white; color: #222222; font-size: 13px;">
<span style="font-family: Courier New, Courier, monospace;"> AnotherPropertyForTheTaskWithA<wbr></wbr>LongName="value2" /</span><span style="font-family: 'Courier New', Courier, monospace;">></span></div>
<div style="background-color: white; color: #222222; font-size: 13px;">
<span style="font-family: Courier New, Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"><</span><span style="font-family: Courier New, Courier, monospace;">MSBuildTaskWithShortName SomeProperty="value3" /</span><span style="font-family: 'Courier New', Courier, monospace;">></span></div>
<div style="background-color: white; color: #222222; font-size: 13px;">
<span style="font-family: Courier New, Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"><</span><span style="font-family: 'Courier New', Courier, monospace;">/Target</span><span style="font-family: 'Courier New', Courier, monospace;">></span></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px;">
</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px;">
The properties don't line up ("SomeProperty" not aligned with the properties from the previous task) making it a bit harder to read.</div>
<h4>
Good</h4>
<div style="background-color: white; color: #222222; font-size: 13px;">
<span style="font-family: Courier New, Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"><</span><span style="font-family: Courier New, Courier, monospace;">Target Name="MyExampleTarget3"</span><span style="font-family: 'Courier New', Courier, monospace;">></span></div>
<div style="background-color: white; color: #222222; font-size: 13px;">
<span style="font-family: Courier New, Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"><</span><span style="font-family: Courier New, Courier, monospace;">SomeMSBuildTaskThatDoesSomethi<wbr></wbr>ngOrOtherWithALongName </span></div>
<div style="background-color: white; color: #222222; font-size: 13px;">
<span style="font-family: Courier New, Courier, monospace;"> SomePropertyForTheTaskWithALon<wbr></wbr>gName="value1"</span></div>
<div style="background-color: white; color: #222222; font-size: 13px;">
<span style="font-family: Courier New, Courier, monospace;"> AnotherPropertyForTheTaskWithA<wbr></wbr>LongName="value2" /</span><span style="font-family: 'Courier New', Courier, monospace;">></span></div>
<div style="background-color: white; color: #222222; font-size: 13px;">
<span style="font-family: Courier New, Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"><</span><span style="font-family: Courier New, Courier, monospace;">MSBuildTaskWithShortName </span></div>
<div style="background-color: white; color: #222222; font-size: 13px;">
<span style="font-family: Courier New, Courier, monospace;"> SomeProperty="value3" /</span><span style="font-family: 'Courier New', Courier, monospace;">></span></div>
<div style="background-color: white; color: #222222; font-size: 13px;">
<span style="font-family: Courier New, Courier, monospace;"> </span><span style="font-family: 'Courier New', Courier, monospace;"><</span><span style="font-family: Courier New, Courier, monospace;">/Target</span><span style="font-family: 'Courier New', Courier, monospace;">></span></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px;">
</div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px;">
Everything almost always fits in the editor window (no need to scroll horizontally) and everything lines up making it easy on the eye.</div>
Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-73598261209883654632012-10-22T19:38:00.000+01:002012-10-22T19:38:08.645+01:0032GB Surface with Windows RT sold out in the UKAll 32GB Surface models have sold out ahead of the launch in the UK!<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiOf7MGxxZIWe4PDme-6jmQuOpFZ_LRawEoMwf5BDBEqmF7yhrMbHUPFYWa8CZE1GpoMM56NYRmei7WDXMO1cEiuychaWvmF6iGDWTGWpKo1m4Rli9aLb_BDZAfD73pOlKcEr-Z5ZH2Eo/s1600/SurfaceSoldOut.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiOf7MGxxZIWe4PDme-6jmQuOpFZ_LRawEoMwf5BDBEqmF7yhrMbHUPFYWa8CZE1GpoMM56NYRmei7WDXMO1cEiuychaWvmF6iGDWTGWpKo1m4Rli9aLb_BDZAfD73pOlKcEr-Z5ZH2Eo/s1600/SurfaceSoldOut.jpg" /></a></div>
<br />Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-31205055327806185832012-07-01T22:24:00.001+01:002012-07-01T22:24:15.569+01:00Everything you thought you know about connection pooling is wrong<span style="font-family: Arial, Helvetica, sans-serif;">See <a href="http://blogs.msdn.com/b/ialonso/archive/2012/06/04/how-to-determine-whether-a-connection-is-pooled-or-nonpooled.aspx" target="_blank">why</a>.</span>Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-43247524159291686312012-02-08T23:02:00.002+00:002012-02-08T23:04:54.567+00:00A minimal SignalR example<p><span style="font-family:arial;">SignalR is an “async signaling library for .NET to help build real-time, multi-user interactive web applications”.</span></p><span style="font-family:arial;"> </span><p><span style="font-family:arial;">And its very cool. A minimal example…</span></p><span style="font-family:arial;"> </span><p><span style="font-family:arial;">Add the “SignalR” NuGet package to a web application:</span></p> <p> <span style="font-family:Courier New;">Install-Package SignalR</span></p> <p><span style="font-family:arial;">The HTML:</span></p> <pre class="csharpcode"><span class="kwrd"><</span><span class="html">html</span><span class="kwrd">></span><br /><span class="kwrd"><</span><span class="html">head</span><span class="kwrd">></span><br /><span class="kwrd"></</span><span class="html">head</span><span class="kwrd">></span><br /><span class="kwrd"><</span><span class="html">body</span><span class="kwrd">></span><br /> <span class="kwrd"><</span><span class="html">script</span> <span class="attr">src</span><span class="kwrd">="../Scripts/jquery-1.6.4.js"</span><span class="kwrd">></</span><span class="html">script</span><span class="kwrd">></span><br /> <script src=<span class="str">"../Scripts/jquery.signalR.js"</span>></script><br /> <script src=<span class="str">"../signalr/hubs"</span>></script><br /> <form id=<span class="str">"form1"</span> runat=<span class="str">"server"</span>><br /> <div><br /> <script type=<span class="str">"text/javascript"</span>><br /> <span class="kwrd">var</span> chat;<br /> <br /> $(<span class="kwrd">function</span> () {<br /> <span class="rem">// Created proxy</span><br /> chat = $.connection.myChat;<br /><br /> <span class="rem">// Assign a function to be called by the server</span><br /> chat.addMessage = onAddMessage;<br /><br /> <span class="rem">// Register a function with the button click</span><br /> $(<span class="str">"#broadcast"</span>).click(onBroadcast);<br /> <br /> <span class="rem">// Start the connection</span><br /> $.connection.hub.start();<br /> });<br /><br /> <span class="kwrd">function</span> onAddMessage(message) {<br /> <span class="rem">// Add the message to the list</span><br /> $(<span class="str">'#messages'</span>).append(<span class="str">'<li>'</span> + message + <span class="str">'</li>'</span>);<br /> }<br /><br /> <span class="kwrd">function</span> onBroadcast() {<br /> <span class="rem">// Call the chat method on the server</span><br /> chat.send($(<span class="str">'#message'</span>).val());<br /> }<br /> <span class="kwrd"></</span><span class="html">script</span><span class="kwrd">></span><br /> <span class="kwrd"><</span><span class="html">input</span> <span class="attr">type</span><span class="kwrd">="text"</span> <span class="attr">id</span><span class="kwrd">="message"</span> <span class="kwrd">/></span><br /> <span class="kwrd"><</span><span class="html">input</span> <span class="attr">type</span><span class="kwrd">="button"</span> <span class="attr">id</span><span class="kwrd">="broadcast"</span> <span class="kwrd">/></span><br /> <span class="kwrd"><</span><span class="html">ul</span> <span class="attr">id</span><span class="kwrd">="messages"</span><span class="kwrd">></</span><span class="html">ul</span><span class="kwrd">></span><br /> <span class="kwrd"></</span><span class="html">div</span><span class="kwrd">></span><br /> <span class="kwrd"></</span><span class="html">form</span><span class="kwrd">></span><br /><span class="kwrd"></</span><span class="html">body</span><span class="kwrd">></span><br /><span class="kwrd"></</span><span class="html">html</span><span class="kwrd">></span></pre><p><span style="font-family:arial;">The code (C#):</span></p><pre class="csharpcode"> <span class="kwrd">using</span> SignalR.Hubs;<br /><br /> <span class="kwrd">public</span> <span class="kwrd">class</span> MyChat : Hub<br /> {<br /> <span class="kwrd">public</span> <span class="kwrd">void</span> Send(<span class="kwrd">string</span> message)<br /> {<br /> <span class="rem">// Call the addMessage method on all clients</span><br /> Clients.addMessage(message);<br /> }<br /> }</pre><p><span style="font-family:arial;">And that is it.</span></p><p><span style="font-family:arial;">Now you have a real-time chat/message application. View the page in multiple browsers and see all the client receive all the messages in real-time.</span></p>Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-7315039350260495472011-12-09T16:39:00.001+00:002011-12-09T17:05:55.132+00:00The only Windows Azure Pricing Calculator you will ever need<p>I wrote this to cost up a project: <a title="https://skydrive.live.com/view.aspx?cid=0DE849CA9FB5B198&resid=DE849CA9FB5B198%21704" href="https://skydrive.live.com/view.aspx?cid=0DE849CA9FB5B198&resid=DE849CA9FB5B198%21704">https://skydrive.live.com/view.aspx?cid=0DE849CA9FB5B198&resid=DE849CA9FB5B198%21704</a></p> <p>For UK currency.</p> <p>Unlike every single other calculator out there it allows you to…</p> <ul> <li>Specify a profile for 5 environments (each profile can differ in number/size of Compute Instances etc):</li> <ul> <li>Integration Test</li> <li>System Test</li> <li>User Acceptance Test</li> <li>Pre-Production</li> <li>Production</li> </ul> <li>Specify how many hours (per week) you need your Compute Instances for (you might be happy to tear down your hosted services each night – if you’re not using them, why pay?)</li> </ul> <p>Monthly and yearly totals shown.</p> Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-76967339334621886482011-11-04T17:20:00.001+00:002011-11-04T17:20:36.025+00:00Windows Azure Pricing<p>Pay as you go: <a title="http://www.microsoft.com/windowsazure/offers/MS-AZR-0003P" href="http://www.microsoft.com/windowsazure/offers/MS-AZR-0003P">http://www.microsoft.com/windowsazure/offers/MS-AZR-0003P</a></p> <p>What qualifies as a transaction in Windows Azure Storage (you pay per transaction): <a title="http://blogs.msdn.com/b/windowsazurestorage/archive/2010/07/09/understanding-windows-azure-storage-billing-bandwidth-transactions-and-capacity.aspx" href="http://blogs.msdn.com/b/windowsazurestorage/archive/2010/07/09/understanding-windows-azure-storage-billing-bandwidth-transactions-and-capacity.aspx">http://blogs.msdn.com/b/windowsazurestorage/archive/2010/07/09/understanding-windows-azure-storage-billing-bandwidth-transactions-and-capacity.aspx</a></p> <p>MSDN Benefits for Windows Azure: <a title="http://www.microsoft.com/windowsazure/msdn-benefits/" href="http://www.microsoft.com/windowsazure/msdn-benefits/">http://www.microsoft.com/windowsazure/msdn-benefits/</a></p> Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-4310840630655383202011-11-03T22:32:00.001+00:002011-11-03T22:39:57.683+00:00Windows Azure and operational cost reduction<p>One of the things that strikes me the most about using Windows Azure (or most cloud solutions) is the savings you can make with your test environments.</p> <p>In Windows Azure world, your on-going cost is for your <a href="http://www.microsoft.com/windowsazure/features/compute/" target="_blank">Compute instances</a> (what you deploy your applications to) and your storage. Whether you are using the application or not, you are paying money for your Compute instances and storage to exist. Other costs (Access Control, CDN etc) you pay per use or transaction.</p> <p>So if you have a system test or user acceptance test environment that you are not using, you can simply delete the Compute instances and any storage artefacts. Then you don’t pay for them.</p> <p>Contrast this will your on premise applications. You probably have multiple test environments for different projects and those are sitting there, costing you money whether you use them or not.</p> <p>Some people suggest that Windows Azure (and some other cloud services are not that cheap). I disagree. Let’s say I need a system test environment for 5 days a month. A “Large” Compute instance (4 x 1.6GHz, 7GB RAM, 1000GB storage) costs $0.48/hour. Well 5 days at 8 hours a day (most people don’t work 24/7) costs me $19.20 (this includes the operating system license). I can <a href="http://wappowershell.codeplex.com/" target="_blank">script</a> the creation of my compute instances and other artefacts very simply, so automatically spinning up or shutting down assets on demand.</p> <p>So, a pretty meaty server for a system test environment on Windows Azure costs me $19.20 for the 5 days per month I want to use it.</p> <p>How much is your on premise hardware costing to run for a whole month?</p> Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-80152855692419792282011-11-01T14:17:00.001+00:002011-11-01T14:17:45.953+00:00PowerShell, MSBuild and 64-bit platforms<p>If you call PowerShell from MSBuild on a 64-bit platform, you will often get unexpected errors. One such error is as follows:</p> <blockquote> <p><font face="Courier New">No snap-ins have been registered for windows powershell version 2</font></p> </blockquote> <p>The probable cause is that the MSBuild executable you are running is not 64-bit. On 64-bit platforms you should execute MSBuild from the following location:</p> <blockquote> <p><font face="Courier New">%SystemDrive%\Windows\Microsoft.NET\Framework<font color="#ff0000"><strong>64</strong></font>\v4.0.30319\msbuild.exe</font></p> </blockquote> <p>Depending on how/what you have installed, your Start Menu shortcuts might be pointing to the 32-bit version.</p> Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0tag:blogger.com,1999:blog-3070727340982558956.post-81114864510180271892011-10-31T13:16:00.001+00:002011-10-31T13:16:01.620+00:00Elegantly testing for a PowerShell Snap-In<p>This PowerShell script tries to load the WAPPSCmdlets snap-in, fails silently if the loading of the snap-in fails (if it isn’t installed), advises the user and exits from the script.</p> <blockquote> <p><font face="Courier New">if ((Get-PSSnapin | ?{$_.Name -eq "WAPPSCmdlets"}) -eq $null) <br />{ <br />  Add-PSSnapin WAPPSCmdlets -erroraction SilentlyContinue <br />  $SnapIn = GET-PSSnapIn WAPPSCmdlets -erroraction SilentlyContinue <br />  if ($SnapIn -eq $null) <br />  { <br />    Write-Error "To run this script the 'Windows Azure Platform PowerShell Cmdlets' are required." <br />    Write-Error "Please download from '</font><a href="http://wappowershell.codeplex.com/'"><font face="Courier New">http://wappowershell.codeplex.com/'</font></a><font face="Courier New"> and install as a PowerShell Snap-in (not as a Module)." <br />    Exit <br />  } <br />}</font></p> </blockquote> <p>I’m testing for “WAPPSCmdlets” but you could test for any PowerShell Snap-in.</p> <p><a href="http://www.comparethemeerkat.com/" target="_blank">Simples</a> (if you don’t <a href="http://en.wikipedia.org/wiki/Aleksandr_Orlov_(advertising)" target="_blank">get it</a>).</p> Callum Hibberthttp://www.blogger.com/profile/15087498670872017678noreply@blogger.com0