Monday, February 28, 2011

Windows Azure SDK Refresh released

I noticed it a little late, but Microsoft released a refresh of the Windows Azure November 2010 SDK(1.3). I still want to mention it because it solves a security issue with the Windows Azure Software Development Kit (SDK).  I strongly encourage you to install the refresh of the SDK and redeploy your application(s).

Who is affected?

This issue affects applications developed using ASP.NET and using the new "Full IIS" feature of SDK v1.3 that have a Web Role deployed.

In particular, this affects web sites and services that use cookies to maintain state information either within a session or between sessions (if interactions in one session can affect what happens in a subsequent session). These cookies are cryptographically protected so that clients can see that there is state information being passed but cannot see the contents of that state information and cannot change it. In the case of vulnerable Web Roles, it may be possible for clients to determine the contents of the state information (though the client could still not change it). If the web site depended on the client not being able to see the contents, its security could be compromised.

Applying the fix

To apply the fix:

1.     Download and install the refresh of the November 2010 Tools and SDK (recommended).

2.     To upgrade just the SDK, use this link (64 bit) or this link (32 bit)

After you've applied the fix, you'll have to re-package your service and then upgrade or re-deploy your service in the cloud.

Verifying the fix

To verify the fix has been applied:

1.     Check the version number of 'Windows Azure SDK' after upgrading to this refresh, as displayed under 'Programs and Features.' It should be 1.3.20121.1237.

Sunday, February 27, 2011

Azure Design Patterns

With the introduction of Cloud Computing and Windows Azure a whole new range of architectural paradigms and patterns arise at the horizon. But which patterns are out there and where do I get started?

That’s where Windows Azure MVP David Pallmann’s Azure Design Patterns site comes in handy. Why do all the work yourself when you can go to one place and see it all, organized in a way that’s easy to navigate?

AzureDesignPatterns

From the same organization I can also recommend the Azure ROI Calculator, a free tool to calculate the cost of your transition to the cloud.

AzureROICalculator

Saturday, February 26, 2011

Free WPF Controls

Mindscape had something to celebrate and therefore announced that you can now download a free version containing fully functional versions of the CoverFlow, AutoCompleteBox and PromptDecorator controls. You can use these controls to create attractive, helpful user experiences and it won’t cost you a cent!

CoverFlow

AutoCompleteBox

PromptDecorator

Remark: Also have a look at LightSpeed, their .NET domain modelling and O/R mapping framework, one of the best (designer-enabled) ORM tools I’ve ever tried(and unfortunately I tried a lot…).

Friday, February 25, 2011

Showing images in jQuery grid

For a customer project I had to show an image in a jQuery grid row.

Doing this is not very hard. Just return the HTML element as your grid column's data. The field should be something like this:

<img src=../images/sample.jpg> 
Remark: Do not use ' or " for the src, it will not work properly. 

Thursday, February 24, 2011

Enable classic ASP support on Windows Azure

The easiest way to enable classic ASP support on Windows Azure is by using a start-up task. Start-up tasks were added in the SDK 1.3 release and allow you to configure a virtual machine instance when it’s created.

So we will define a start-up task to set up the webrole and enable classic ASP support. To do this, open the ServiceDefinition.csdef file in the Windows Azure project, locate the WebRole element in the service model and inside it, insert a Startup element with a single task, as shown below.

<ServiceDefinition name="CloudService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="ClassicWebApp">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="HttpIn" endpointName="HttpIn" />
</Bindings>
</Site>
</Sites>
<ConfigurationSettings>
</ConfigurationSettings>
<Endpoints>
<InputEndpoint name="HttpIn" protocol="http" port="80" />
</Endpoints>
<Imports>
<Import moduleName="Diagnostics" />
</Imports>
<Startup>
<Task commandLine="start /w pkgmgr /iu:IIS-ASP" executionContext="elevated" taskType="simple" />
</Startup>
</WebRole>
</ServiceDefinition>

Note: The Startup element contains one or more Tasks that the role executes during its bootstrapping process. Each task includes a commandLine parameter that defines a program or a batch file to execute.

Tasks can specify an executionContext that allows them to run in the same security context as the role or with administrative privileges. Because registering a COM component requires writing information to a registry hive that is not accessible to regular users, the registration task uses an elevated execution context.

Additionally, tasks can specify a type that determines how they are scheduled. The following types are available:

  • Simple: the startup process launches the task and does not proceed until the task completes.
  • Background: the startup process launches the task in the background and then continues.
  • Foreground: similar to a background task, but the role cannot shut down until all the foreground tasks have ended.

Wednesday, February 23, 2011

Driving your career

Last year Brian Prince did a 32 part screencast series called “Driving Your Career”. This series covered different skills you need to further your career. He covered skills like problem solving, critical thinking, and body language.

A must see for every IT professional!

career

Tuesday, February 22, 2011

Converting a website project to a web application project

Because I had some trouble with source control integration of a website project I decided to convert it back to a web application. But how do you do this? Turns out that this is not a one step process.

The best strategy for converting an existing Web site project is to first create a new, blank Web application project in a separate directory. This avoids changing any part of the existing Web site project files. It also enables you to copy existing functionality into the new Web application project.

Step 1 -  Create a new Web application project
  1. In the File menu, click New, and then click Project.
  2. The New Project dialog box is displayed.

  3. In the Project types section of the New Project dialog box, expand the language that you want to use, and then select Web to display the Web-related templates.

  4. Select ASP.NET Empty Web Application.

  5. Type values for Name, Location, and Solution Name, and then click OK to create the Web application project.

Step 2 -Add required references to the Web application project
  1. In Solution Explorer, right-click References, and then click Add Reference.

    The Add Reference dialog box is displayed.

  2. Select the references that you want to add and then click OK.

  3. In Solution Explorer, right-click the Web application and click Build.

    Visual Studio builds the project and verifies that any project-to-project references are working.

Step 3 - Copy the Web site files to the Web application project
  1. In Solution Explorer, right-click the Web site project and select Open Folder in Windows Explorer.

  2. Select the files of the Web site project to copy.

  3. Right-click the selected files and then click Copy.

  4. In the Web application project, right-click the Web application project and click Open Folder in Windows Explorer.

  5. Paste the Web site project files into the Web application project directory.

  6. In Solution Explorer of the Web application project, click the Show All Files button.

  7. Select the new files in Solution Explorer.

  8. Right-click the selected files and then click Include In Project.

Step 4 - Converting the Project Files

Visual Studio includes an option to convert pages and classes in Web application projects to use partial classes. Partial classes are used to separate the markup in a page or user control code-behind code. These designer-generated classes are stored in a separate file from the code-behind file.

The conversion process causes Visual Studio to recursively examine every page, master page, and user control in the project, and to automatically generate a .designer.cs or .designer.vb file for each. Visual Studio also changes the .aspx or .ascx files to use the codeBehind attribute instead of the codeFile attribute. This conversion process also renames the App_Code folder to Old_App_Code.

To convert pages and classes to use partial classes in a Web application project
  1. In Solution Explorer, right-click the root project folder that contains the pages and classes that you want to convert, and then click Convert to Web Application.

  2. Build the project to see whether there are any compilation errors.

For more information, check the MSDN documentation.

Monday, February 21, 2011

Localhost traffic debugging with Fiddler

While reading about the IE 9 RC, I noticed one feature that will make my life a lot easier:

  • Debugging of traffic sent to Localhost / 127.0.0.1 now “just works”—configuration changes are not required.

Normally Internet Explorer will automatically bypass a fixed proxy (like Fiddler) for traffic bound for //localhost and //127.0.0.1 because these “loopback” addresses point to the local machine and traditional proxy servers will not be able to interpret such addresses properly. However, for a debugging proxy running on the local computer, these are perfectly understandable addresses, and when you are debugging against a local server (like IIS Express or the ASP.NET Development Server Cassini) they often test against these loopback addresses. To proxy loopback traffic from IE8 and below, somewhat awkward workarounds are needed.

IE9 RC introduces the ability to proxy loopback traffic. To do so, simply include the token <-loopback>  in the proxy bypass list. When IE encounters this token in the bypass list, it will remove the loopback addresses (localhost, 127.0.0.1) from the list of hosts that bypass the proxy. Fiddler 2.3 and above automatically set this option when capturing traffic.

Internet Control Panel Proxy Exception list showing minus-loopback token

Read more about this and other features here.

Sunday, February 20, 2011

Disable #regions in Visual Studio

2 weeks ago I gave a presention for the VISUG. During the presentation I mentioned that I hated the use of #regions in source code.  Each time you use the Visual Studio helpers you will get a region tag around the interface implementations. Someone in the audience mentioned that I could disable this behavior.

So after the presentation I opened Visual Studio again and found the option to disable this:

Tools –> Options… -> Text Editor –> C# –> Advanced –> Implement Interface

image

Deactivate this checkbox and bye bye “#region…”

Monday, February 14, 2011

Load testing with Fiddler

For one of our projects, we wanted to do some load testing to validate if our infrastructure was sufficient. We decided not to use the Visual Studio Load testing features.

Instead we choose StressStimulus, a free Fiddler plug-in for easy load testing of web applications.

StresStimulus plays back HTTP requests recorded in Fiddler to create high concurrency workload on web applications. You can configure virtual users, think time, and number of test iterations or test duration.


After test completion, StresStimulus determines average performance of the test scenario. It breaks down response times of every page between server and network times to identify areas with scalability problems.

StresStimulus can be downloaded at http://stresstimulus.stimulustechnology.com. It is free, allows unlimited virtual users, and no registration is required.

Remark: When we tried to install the plugin on a 64bit machine, the installation failed. This is a known bug and the problem will be fixed in the next release. You can already download the alpha here.

Sunday, February 13, 2011

Windows Azure AppFabric CTP February Release

The Azure teams keeps adding new functionality at a regular pace. Now they have update the AppFabric CTP with a new February release (available here).

This release delivers a number of enhancements, including:

  • New Silverlight-based LABS portal
  • The option of 128MB or 256MB cache size
  • The ability to dynamically upgrade or downgrade cache size
  • Improved diagnostics with client side tracing and client request tracking capabilities
  • Overall performance improvements

You can also download the latest SDK here.

Saturday, February 12, 2011

Team Explorer Everywhere 2010 SP1 is Available

Microsoft is threating his Team Explorer Everywhere customers well with a SP1 release (Download available at: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=53c27216-c4f0-48b6-9bed-fe1718a2e3b0)

The most important features of the Team Explorer Everywhere 2010 SP1 release are:
  • Fully localizable product.
  • Full Gated check-in support for TFS 2010.
  • Support for rich work item descriptions.
  • A bunch of bug fixes and other improvements.
  • Use Team Explorer Everywhere as a standalone client.
  • Fast Workspace Switching.
  • Source Control Explorer Improvements
  • Improved Kerberos support on non-Windows platforms.
  • Auto-connect on Start-up.

Read more about this on Brian Harry’s blog:

Thursday, February 10, 2011

VISUG Session: Caliburn.Micro–Solving real world problems with MVVM–Sample application

This Tuesday I gave a presentation about Caliburn.Micro for the Visual Studio user group in Belgium(www.visug.be). I already uploaded the presentation, but now I also added the sample application I’ve used. Download it here.

Some interesting parts of the application:

  • The default IoC functionality inside the bootstrapper is replaced by MEF. Check the MefBootstrapper.cs file in the Core folder.
  • Some interesting IResult implementations are also available:
    • BusyResult: Shows/hides a loading indication.
    • ShowScreenResult<T>: Activates a specific screen on the Conductor.
    • QueryResult: Executes a query on the backend and returns the results.
    • CommandResult: Executes a command on the backend.
  • A lightweight CQRS(Command-Query separation) implementation. Check the Model folder.
  • A simple Conductor<T> implementation
  • Convention over configuration
  • And of course all the reasons why Caliburn.Micro is such a great framework:
    • No Code Behind
    • No Event Wireups
    • No Commands
    • No Data Binding
    • No Data Templates
    • No Async Programming

Wednesday, February 9, 2011

Windows Azure Learning plan

Interested in moving to the Cloud and looking for some interesting resources?  Look no further and just go to this post by Buck Woody:

Some of the covered topics:

Architecture

Patterns and practices for Windows Azure, How it works, and internals.

Compute

Information on Web, Worker, VM and other roles, and how to program them.

Storage

Blobs, Tables, Queues, and other storage constructs, and how to program them.

Application Fabric

Service Bus, Authentication and Caching, in addition to other constructs in the Application Fabric space.

Security

General and Specific security considerations, remunerations and remediation.

SQL Azure

SQL Server Azure information for architecting and managing applications in the cloud RDBMS.

Windows Azure and SQL Azure Use-Cases

Use-case patterns for Windows and SQL Azure

VISUG Session: Caliburn.Micro–Solving real world problems with MVVM

Yesterday I gave a presentation about Caliburn.Micro for the Visual Studio user group in Belgium(www.visug.be). We had a full room, the session went well and I received a lot of interesting questions. Thanks everyone for being there!

The presentation is available below. I will upload the sample application and the demos later.

Tuesday, February 8, 2011

Caching in .NET 4

For a long time I have been using the caching application block in Enterprise Library when I needed some caching functionality inside my .NET application. You could also use  System.Web.Caching but it was not extensible,and not easy to use outside an ASP.NET context.

With the release of .NET 4 there is a finally a more mature caching system now included in the framework. This is known as System.Runtime.Caching.  The System.Runtime.Caching namespace contains types that let you implement caching in NET Framework applications.

The output caching functionality and types in the System.Runtime.Caching namespace are new in .NET Framework version 4. The classes in this namespace provide a way to use caching facilities like those in ASP.NET, but without a dependency on the System.Web assembly.

The caching types that are provided in this namespace offers the following features:

  • Caching is accessible to all .NET Framework applications, not just ASP.NET.

  • Caching is extensible.

  • You can create custom caching providers. For example, instead of using the default in-memory cache engine, you can create custom providers that store cache data in databases, in custom objects, or in the file system

The starting class is the abstract ObjectCache which has one concrete implementation the MemoryCache.  To use it first instantiate an instance of the MemoryCache(in this sample I’m using the default instance).  I can check if the cache contains an object using the .Contains method, I retrieve from the cache using the .Get method and I add to the cache using the .Add method.

//Create a cache instance
ObjectCache cache = MemoryCache.Default;     

//check the cache for a specific value
if (cache.Contains("CachedValueKey"))     
{         
//get an item from the cache
var value=cache.Get("CachedValueKey");     
}     
else    
{         
//add an item to the cache 
cache.Add("CachedValueKey", "Some value to cache", new CacheItemPolicy());     
} 

Important to notice is the CacheItemPolicy. In the sample I’m using the default policy but you can configure a lot of options:

  • AbsoluteExpiration: Set a date/time when to remove the item from the cache.
  • ChangeMonitors: Allows the cache to become invalid when a file or database change occurs.
  • Priority: Allows you to state that the item should never be removed.
  • SlidingExpiration: Allows you to set a relative time to remove the item from cache.
  • UpdateCallback & RemovedCallback: Two events to get notification when an item is removed from cache. UpdateCallback is called before an item is removed and RemovedCallBack is called after an item is removed.

Monday, February 7, 2011

Windows Phone 7 Emulator: Shortcut keys

While using the Windows Phone 7 emulator, I was really annoyed that I had to use the on screen keyboard to enter some values. Until a colleague of me mentioned that if you push Page Up on your keyboard, you can just start typing. What a shame that I didn’t know this sooner. So for anyone who is using the WP7 emulator, these are some of the most useful shortcut keys available:

  • F1 : Use F1 key on the keyboard instead of back button on the phone
  • F2 : Use the key F2 on the keyboard for the Windows key in the Windows Phone 7
  • Pageup : Enables the keyboard in the emulator when the focus is on the textbox
  • PageDown : Disables the keyboard in the emulator
  • F3 : To open the Bing Search
  • F7 : To Activate the Physical Camera

For the full list of all shortcuts, have a look at the following MSDN page: Keyboard Mapping for Windows Phone Emulator.

Sunday, February 6, 2011

Windows Azure Training Kit: January update

The Windows Azure Team has just released the January edition of the training kit with new demo scripts, labs for working with Windows Phone 7 and the Cloud, and new and improved code snippets for Visual Studio.

Some of the specific changes with the January update of the training kit includes:

Download the January Update to the Windows Azure Platform Training Kit today.

Saturday, February 5, 2011

Windows Phone Training kit updated

Microsoft recently updated the Windows Phone Training Kit. This update includes a refresh to almost all the labs and also includes some new ones.

The 2 added labs are:

  • Accessing Windows Phone 7 Devices is a lab that lets you work with the phone’s camera and location services. The Windows Phone 7 is equipped with a Camera and GPS (global positioning system). Developers can leverage these devices to build location-aware applications and take live photos. The lab walks you through the steps required to integrate your applications with the phone’s camera. The goal is to build an application that lets you capture pictures, give them a title, and save them to the application local store. The lab also gives you the option to “fake” locations and, when saving a picture to a local store, associate its latitude-longitude (lat-long) geo-coordinates, and create a view in which you can see the pictures on a map.  (This lab uses the Windows Phone GPS Emulator).
  • Multi-touch Game Development with XNA Framework is a lab that introduces you to multi-touch enabled game development on Windows Phone 7 using XNA Game Studio, the Windows Phone Developer tools and Visual Studio 2010. During the lab, you will build a simple 2D game using XNA Game Studio. Playing the game requires the user to supply multi-touch input; this lab will show you how to support these inputs while making sure that the game reacts to them as the user would expect.

Some other interesting lab updates are the Using Chooser and Launcher lab that now show the entire Chooser and Launchers family (except the marketplace) and the Using Push Notification lab that now  uses the latest Windows Phone Push Notification Library.

You can download the full kit, or just the Silverlight or XNA framework labs. The online training kit was also updated.

Friday, February 4, 2011

Visual Studio Out of Memory exceptions

As you probably know Visual Studio requires quite a bit of memory resources, especially if your solution is fairly large. Important to know is that the Visual Studio memory use is limited to 2GB of virtual memory. This is true even when you are running Visual Studio on a 64-bit OS because VS is still a 32-bit application.

When Visual Studio + all Add-Ins memory use gets close to the 2GB limit it throws the OutOfMemoryException which cannot be caught nor handled.

To address this issue to an extent you can make Visual Studio use up to 3GB of virtual memory.

First of all, tell the OS to increase the amount of user-mode memory from 2GB to 3GB. (If you are running on 64-bit, skip this step)

  • For Windows 7: Run the following from the command prompt:
    BCDEDIT /Set IncreaseUserVa 3072

Next step is to make Visual Studio aware of the larger address space:

  • Be sure to backup devenv.exe
  • From the command prompt navigate to "C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE"  and execute the following:
    editbin /LARGEADDRESSAWARE devenv.exe
  • Reboot your computer

Thursday, February 3, 2011

12 keys to success with Agile

I’ve seen projects succeed and I’ve seen projects fail. Yesterday everyone was doing Waterfall, today it’s all Agile.

Although I strongly believe in the values and ideas behind Agile, it is still not a silver bullet. But to get you on the right track, I recommend reading the following blog post: 12 keys to success with agile

Wednesday, February 2, 2011

Azure Diagnostics Monitoring

Do you want to change the diagnostic level or other diagnostic configuration settings in Azure at runtime?  Doing this is very easy thanks to the DeploymentDiagnosticManager class .(See http://msdn.microsoft.com/en-us/library/ee830424.aspx )

To remotely change the configuration

  1. Create a small console application.

  2. Add a referenceMicrosoft.WindowsAzure.Diagnostics.dll file .

  3. Create a CloudStorageAccount instance.

    var storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=AccountName;AccountKey=AccountKey");
  4. Create an instance of the DeploymentDiagnosticManager. :

    var diagManager = new DeploymentDiagnosticManager(storageAccount, "<DeploymentID>"); 

    The<DeploymentID> can be found on the Azure Management Portal.

  5. Create a role instance diagnostic manager.

    var instanceManagers = diagManager.GetRoleInstanceDiagnosticManagersForRole("<RoleName>");
    

    The <RoleName> can be found on the Azure Management Portal.

  6. Specify the configuration information that you want to change. The following code example shows how to set performance counter information:

    PerformanceCounterConfiguration pccCPU = new PerformanceCounterConfiguration();
    pccCPU.CounterSpecifier = @"\Processor(_Total)\% Processor Time";
    pccCPU.SampleRate = TimeSpan.FromSeconds(5);
    
    PerformanceCounterConfiguration pccMemory = new PerformanceCounterConfiguration();
    pccMemory.CounterSpecifier = @"\Memory\Available Mbytes";
    pccMemory.SampleRate = TimeSpan.FromSeconds(5);
    
  7. Change the configuration for each instance of the role. The following code example shows how to iterate through the role instances and change the configuration:

    foreach (var roleInstance in instanceManagers)
    {
    DiagnosticMonitorConfiguration currentConfiguration = roleInstance.GetCurrentConfiguration();
    
    currentConfiguration.PerformanceCounters.DataSources.Add(pccCPU);
    currentConfiguration.PerformanceCounters.DataSources.Add(pccMemory);
    
    //Update the configuration
    roleInstance.SetCurrentConfiguration(currentConfiguration);
    }
    
  8. Save and build the project.