Monday, December 31, 2012

NUnit Test Adapter for Visual Studio 2012 updated

Starting from Visual Studio 2012 the testing infrastructure became extensible making it possible to add support for other test frameworks without the need of 3th party plugins like Resharper or Gallio.

Just before the year ended, the NUnit team released a new version(beta 4) of their NUnit Test Adapter for Visual Studio, with support for VS 2012 Update 1. The new release, version 0.94, works with the VS 2012 RTM as well but shows off some extra features when used with the update.

The biggest addition to the Adapter in this release is that it now supports Traits. NUnit Properties and Categories are translated in to Visual Studio traits and you can sort the display of tests by trait or filter on them. This goes a long way toward making the Visual Studio Test Explorer useful in running large sets of tests.

Release notes for this version can be found here: http://nunit.org/index.php?p=vsTestAdapterReleaseNotes&r=2.6.2

More information about Traits here: http://blogs.msdn.com/b/visualstudioalm/archive/2012/11/09/how-to-manage-unit-tests-in-visual-studio-2012-update-1-part-1-using-traits-in-the-unit-test-explorer.aspx

Friday, December 21, 2012

Team Foundation Server 2012 Monitoring Management Pack

Last week Microsoft released the Visual Studio 2012 Team Foundation Server Monitoring Management Pack for monitoring TFS with System Center Operations Manager 2007 SP1 or 2012. You can download it here.

The Team Foundation Server 2012 Monitoring Management Pack provides both proactive and reactive monitoring of Microsoft Team Foundation Server 2012. It monitors TFS components such as application tier server instances, team project collections, build servers, and proxy servers.

Feature Summary
The monitoring provided by this management pack includes availability and configuration monitoring, performance data collection, and default thresholds. You can integrate the monitoring of Team Foundation Server components into your service-oriented monitoring scenarios.

  • Auto discovery of TFS components
  • Implements containment hierarchy, reflecting logical architecture of the Product
  • Implements a proper health model using Monitors
  • Contains tasks, diagnostic and recovery for certain failures
  • Provides events that indicate service outages
  • Provides alerts that show configuration issues and connected data source changes
  • Verification that all dependent services are running

HealthExplorer

Thursday, December 20, 2012

Native JSON parsing

Starting from Internet Explorer 8+, Firefox 3.1+, Safari 4+, Chrome 3+, and Opera 10.5+ browsers support native JSON parsing. But what if your users are still using IE7 (or even worse IE6)?

Here are some of the options I prefer to use:

  • To convert a JSON response to a JavaScript object:
    • If you are using jQuery, use parseJSON. Internally it checks if browser supports JSON.parse, so the fallback is built in.
    • Use the JSON.parse method from the json2.js library from Douglas Crockford. It adds a JSON object to the browser if it doesn’t exists yet.
  • To convert a JavaScript object to serialized JSON string:
    • For jQuery I couldn’t find an out-of-the-box solution, but the following jQuery plugin could do the trick: jQuery.toJSON
    • Use the JSON.stringify method from the json2.js library.

What I also like about the json2.js library from Douglas Crockford is that it allows you to manipulate the serialization process by adding a toJSON method to your JavaScript objects.

When an object value is found, if the object contains a toJSON method, its toJSON method will be called and the result will be stringified. A toJSON method does not serialize: it returns the value represented by the name/value pair that should be serialized, or undefined if nothing should be serialized. The toJSON method will be passed the key associated with the value, and this will be bound to the value

For example, this would serialize Dates as ISO strings:

Date.prototype.toJSON = function (key) {
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}

return this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z';
};

Wednesday, December 19, 2012

Updating a Linq to SQL dbml file

As you probably know Microsoft started its journey in ORM land with 2 frameworks: Linq to SQL, a lightweight ORM with some nice features and good performance but tightly coupled to SQL Server and Entity Framework which started as an ugly beast but is now transformed into a good, performant Enterprise ready ORM solution.

So Microsoft decided to stop investing in Linq to SQL and put al its effort in Entity Framework. This means that although Linq to SQL is a nice ORM framework, it’s missing some useful features.

Last week I got a question from a colleague about Linq to SQL. He couldn’t find a way to update the Linq to SQL DBML file so it reflects the changes he made to the underlying database model.

This is just one of the missing features. Luckily there are some workarounds to fix this:

  • Option 1: Remove the changed tables from the DBML designer and drag them again from the SQL explorer window.
  • Option 2: Use the SqlMetalPlus addin. The add-in adds some extra context menu options to all the DBML files in the solution.
    • Create Mapping XML: This command just creates the initial mapping file for you to customize. It just creates a copy of DBML file and changes the file name.
    • Apply Customization: This command applies the custom changes to the existing DBML file.
    • Create/Refresh: This command either creates the initial DBML (or) refreshes the complete DBML with the latest changes from the selected database and then applies the custom changes.

Tuesday, December 18, 2012

Bundling conventions in ASP.NET Bundling and Minification

I talked about the Bundling and Minification NuGet package before. Last week when configuring a new ASP.NET MVC 4 web application, I discovered another nice feature inside this library. Before I had to update the script references each time I upgraded to a new version of jQuery. So somewhere in my code I had a script reference like this:
<script type="text/javascript" language="javascript" src="~/scripts/jquery-1.7.1.js"/>

With the Bundling and Minification library you can create a version independent bundle and set the reference once. So you no longer have to upgrade your script references.

You can see this already in action if you created a new ASP.NET MVC application in Visual Studio 2012.  If you open up  the App_Start\BundleConfig.cs file and examine the RegisterBundles method, you’ll find the following code:

public static void RegisterBundles(BundleCollection bundles)
{
     bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
  "~/Scripts/jquery-{version}.js"));
}
The preceding code creates a new JavaScript bundle named ~/bundles/jquery that includes all the appropriate (that is debug or minified but not .vsdoc) files in the Scripts folder that match the wild card string "~/Scripts/jquery-{version}.js". With a debug configuration, the file jquery-1.7.1.js will be added to the bundle. In a release configuration, jquery-1.7.1.min.js will be added.

The bundling framework follows several common conventions such as:
  • Selecting “.min” file for release when “FileX.min.js” and “FileX.js” exist. 
  • Selecting the non “.min” version for debug.
  • Ignoring “-vsdoc” files (such as jquery-1.7.1-vsdoc.js), which are used only by IntelliSense.
The {version} wild card matching shown above is used to automatically create a jQuery bundle with the appropriate version of jQuery in your Scripts folder. In this example, using a wild card provides the following benefits:
  • Allows you to use NuGet to update to a newer jQuery version without changing the preceding bundling code or jQuery references in your view pages. 
  • Automatically selects the full version for debug configurations and the ".min" version for release builds.

Nice!

Monday, December 17, 2012

Team Foundation Server Sidekicks 2012

Last week Attrice released their Team Foundation Server 2012 version of the Team Foundation Sidekicks.

It offers the same functionality as previous versions but adds support of TFS both on premise and in-the-cloud (Team Foundation Service).

Download version 4.5 of Team Foundation Sidekicks (only for Visual Studio© 2012, Team Foundation Server 2012 and Team Foundation Service).

Friday, December 14, 2012

SignalR Performance Counters

One of the hidden gems in the SignalR framework is a utility called signalr.exe (in the Microsoft.AspNet.SignalR.Hosting.Utils package) that you can use to do a few things.

  • Install/Uninstall SignalR performance counters
  • Generate a static js file for the magic ~/signalr/hubs url.

After installing the Microsoft.AspNet.SignalR.Hosting.Utils NuGet package, you’ll find a SignalR executable in the package folder(under \packages\Microsoft.AspNet.SignalR.Hosting.Utils.1.0.0-alpha2\tools)

  • Open a command prompt(run as Administrator).
  • Browse to the tools folder containing the SignalR.exe file.
  • Run signalr ipc to install the Performance Counters. These performance counters give you more detailed information about your SignalR applications.

clip_image002

    • Remark: To use these on full IIS you need to add the app pool user for your application to the Performance Monitor Users group.
  • Run signalr ghp /path:<path to binaries> to generate a static JavaScript file containing the hub code. This file(server.js) is generated inside the same tools folder.

image

  • If we open up the file we see the magic that SignalR creates for us when calling the ~/signalr/hubs url:
/*!
* ASP.NET SignalR JavaScript Library v1.0.0
* http://signalr.net/
*
* Copyright Microsoft Open Technologies, Inc. All rights reserved.
* Licensed under the Apache 2.0
* https://github.com/SignalR/SignalR/blob/master/LICENSE.md
*
*/

/// <reference path="..\..\SignalR.Client.JS\Scripts\jquery-1.6.2.js" />
/// <reference path="jquery.signalR.js" />
(function ($, window) {
/// <param name="$" type="jQuery" />
"use strict";

if (typeof ($.signalR) !== "function") {
throw new Error("SignalR: SignalR is not loaded. Please ensure jquery.signalR-x.js is referenced before ~/signalr/hubs.");
}

var signalR = $.signalR;

function makeProxyCallback(hub, callback) {
return function () {
// Call the client hub method
callback.apply(hub, $.makeArray(arguments));
};
}

function registerHubProxies(instance, shouldSubscribe) {
var key, hub, memberKey, memberValue, subscriptionMethod;

for (key in instance) {
if (instance.hasOwnProperty(key)) {
hub = instance[key];

if (!(hub.hubName)) {
// Not a client hub
continue;
}

if (shouldSubscribe) {
// We want to subscribe to the hub events
subscriptionMethod = hub.on;
}
else {
// We want to unsubscribe from the hub events
subscriptionMethod = hub.off;
}

// Loop through all members on the hub and find client hub functions to subscribe/unsubscribe
for (memberKey in hub.client) {
if (hub.client.hasOwnProperty(memberKey)) {
memberValue = hub.client[memberKey];

if (!$.isFunction(memberValue)) {
// Not a client hub function
continue;
}

subscriptionMethod.call(hub, memberKey, makeProxyCallback(hub, memberValue));
}
}
}
}
}

signalR.hub = $.hubConnection("/signalr", { useDefaultPath: false })
.starting(function () {
// Register the hub proxies as subscribed
// (instance, shouldSubscribe)
registerHubProxies(signalR, true);

this._registerSubscribedHubs();
}).disconnected(function () {
// Unsubscribe all hub proxies when we "disconnect". This is to ensure that we do not re-add functional call backs.
// (instance, shouldSubscribe)
registerHubProxies(signalR, false);
});

signalR.testHub = signalR.hub.createHubProxy('testHub');
signalR.testHub.client = { };
signalR.testHub.server = {
test: function () {
/// <summary>Calls the Test method on the server-side TestHub hub.&#10;Returns a jQuery.Deferred() promise.</summary>
return signalR.testHub.invoke.apply(signalR.testHub, $.merge(["Test"], $.makeArray(arguments)));
}
};

}(window.jQuery, window));

Thursday, December 13, 2012

Generating QR codes quick and easy in Windows 8

You all probably seen QR codes before, these strange looking images containing any kind of data. Most of the times there are used to embed an URL but you can put any kind of data in it

For a Windows 8 application I’m building I wanted to embed the option to generate QR codes and share these codes using the Windows 8 Share Contracts. The easiest way I found to generate QR codes is by using the Google Chart API. The only thing you need to do is specify the size in pixels of your barcode and the url you wish to encode.

If you invoke a GET request to the Google Chart API using the following query string, you’ll get a generated QR image back:

http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl=http://bartwullems.blogspot.com

Nice and simple!

Wednesday, December 12, 2012

TFS API Blog Series

Since 2009 Shai Raiten is writing about TFS API making his blog one of the best resources for any information about customizing and extending Team Foundation Server.

This resulted in a long list of blog posts:

Basic

Source Control

Testing

Work Items – Definitions and Queries

Areas and Iterations

Builds

Keep going Shai!

Tuesday, December 11, 2012

TFS Publishing to Windows Azure Websites: What to do if you have multiple projects/solutions?

Last week I enabled TFS publishing for a Windows Azure Website.  However the deployment failed because I had multiple projects inside the solution and the build tried to deploy the wrong project.

To fix this I used the following workaround:

  • Create a separate solution for the project you want to deploy and check this solution into source control.
  • Open Team Explorer and connect to your TFS project

image

  • Right click on the Build definition that was created for you when enabled TFS publishing and choose Edit Build Definition...

image

  •    Go to the Process tab and change the Solution To Build to the solution you just created.

image

  • Next time you check in the new solution is used to build and deploy the project.

image

Monday, December 10, 2012

Windows Phone 8 Jump Start training

Last week the Windows Phone team hosted the Windows Phone 8 Jump Start training, a fast-paced and demo-packed learning ‘experience’ tailored to show developers how to build responsive, appealing, and effective applications quickly. All 20 modules are now available online for your on-demand viewing, (or download) on Channel 9.

If you are new to Windows Phone 8, this is a great way to start developing apps right away.

windows-phone-8-start

Friday, December 7, 2012

Toad for Cloud Databases

Looking for a free(!) tool to connect to your Cloud databases? One of the tools I’ve been trying is Toad for Cloud Databases, a free SQL-based tool with the familiar look and feel of Toad, which enables users to use SQL(yes indeed SQL) with a set of  non-relational databases, including Hadoop (Hbase & Hive), Cassandra, MongoDB, SimpleDB, and Azure Table Services.

How does it work?

There are two key components to Toad for Cloud Databases:

  • Toad client: Use it to access Cloud/NoSQL databases via SQL statements.
  • Data Hub: It translates SQL statements submitted through the Toad client into a language understood by the Cloud database, and returns results in the familiar tabular row and column format.
Installation

You can download it from the following location(you’ll have to register first): http://toadworld.com/Freeware/ToadforCloudDatabasesFreeware/tabid/842/Default.aspx

Run the installer after downloading has completed.

Get started
  • Start the Toad for Cloud Databases client. Once the client is loaded you’ll see the Data Explorer on the left.

image

  • Right click on the Embedded Data Hub and choose Map Data Source…

image

  • The Map Data Source wizard is loaded. Specify a Data source name and choose the appropriate Data source type(we’ll choose Azure Table Services).

image

  • Specify the credentials to connect to your data source and click OK to complete this step.

image

  • The data source is added to the Tree view.

image

  • However before we can start doing something, we have to create a mapping first. Right click on the Mappable Objects and choose Map Multiple Tables…

image

  • The Map Tables screen is loaded. Select the Table you want to map and click OK.

image

  • The tool will create a Table for us and map all the found columns as can be seen in the Data Explorer Tree view.

image

  • Now we can right-click on the created table and start writing SQL by choosing Open SQL Editor.

image

  • A SQL Editor is opened and you can write and execute SQL statements.

image

  • That’s it!

Thursday, December 6, 2012

Team Foundation Server: Choosing a Process Template

One of the hardest parts of Team Foundation Server is choosing the right Process Template. The process template defines the set of work item types, queries, and reports that you will use to plan and track your project. Once you’ve created your Team Project, switching to a different Process Template is not an option. So you better choose right…
To help you through the process Microsoft provided a great MSDN article providing lot’s of information about the default templates.
It provides you some considerations to help you choose:
A comparison between the templates:
image
And even a nice overview of the different workflows:
image
Go check it out!

Wednesday, December 5, 2012

TFS Administration Tool 2.2 Released

The TFS Administration Tool has been updated to use the Team Explorer 2012 DLL’s. So you no longer need to install Team Explorer 2010 to use this tool.

Download TFS Administration Tool 2.2 (1.55 MB, MSI)

The TFS Administration Tool allows Team Foundation Server administrators to manage user permissions on all three platforms utilized by Team Foundation Server:

  1. Team Foundation Server,
  2. SharePoint, and
  3. SQL Server Reporting Services.
The tool also allows administrators to easily copy user permissions among team projects and to easily identify any missing permissions on any of the three platforms.

Tuesday, December 4, 2012

Team Foundation Server Source Control Explorer Extension

Last week when searching for an easy solution to delete some files from the TFS database, I found the following Visual Studio Extension: TFSSCExplorerExtension.

“TFSSCExplorerExtension (Team Foundation Server Source Control Explorer VS 2010 Extension) is  aVisual Studio 2010 Extension Package that adds new features to the TFS Source Control Explorer window for TFS 2010. ”

A separate release is available for Visual Studio 2012 here.

It offers the following features:

  • Move to Folder: Move support for multiple files.
  • Branch to Folder: Branch support for multiple files.
  • Merge from Sources: Select items to Merge.
  • File Icon Change: Branched files are shown with a different icon.
  • Drag & Drop: Adds drag & drop support between file list in the left side and folder tree in the right side.
  • Show/Hide deleted items: Quicker alternative then going to Tools – Options.
  • Destroy: Permanently removes files or folders from Source Control.

TFSSCExplorerExtension

Monday, December 3, 2012

ASP.NET MVC: Compile your views up front

For a project I’m doing we had to start a large refactoring round. Therefore it would be useful to get compiler errors on our ASP.NET MVC Views too. Otherwise we had to go through all the screens our self to detect problems.

Luckily ASP.NET MVC offers this feature out-of-the-box:

  1. Unload your ASP.NET MVC project by right right clicking the project on the solution explorer in VS and choosing unload project
  2. Right click on the csproj file name and choose Edit.
  3. Somewhere in the csproj file you’ll find the following line:
    <MvcBuildViews>false</MvcBuildViews>

  4. Change the MvcBuildViews value from false to true.

  5. Save the file and reload your project.

From this moment on the views are compiled too each time you build your project.

Friday, November 30, 2012

WPF 4.5: Airspace problem solved(...or not)

The airspace problem was one of the most annoying issues when integration a Win 32 component(like WinForms) with WPF. The problem is that each render technology belongs to only one airspace only. So when you place Win32 components in your WPF application they behave as a black hole for input leading to all kind of issues.
I blogged about this issue before and even showed a possible workaround.
With WPF 4.5 the issue is finally solved!
To do this 2 extra properties are added to the HwndHost class(the base class for WindowsFormsHost): IsRedirected and CompositionMode.
  • IsRedirected: Set this property to true to solve the airspace problem. (It’s not enabled by default.)
  • CompositionMode: Specified how deep the integration should go. It has multiple possible values:
    • None: this is the default behavior and no integration is done: the airspace problems are still here.
    • OutputOnly: The airspace problem are solved but the user (and the input system) can’t interact with the hosted win32 component.
    • Full: the airspace problems are solved and interaction with the win32 component is possible.
Remark: These two properties have to be set before any rendering is done otherwise an exception will be thrown.

Remark 2: Someone mentioned in the comments that this feature is removed in the final version of .NET 4.5. I double checked it and indeed I couldn't find it :-(

On the MSDN forums I found the following info from the .NET 4.5 Beta Readme - http://go.microsoft.com/fwlink/?LinkId=237569

1.3.10 Windows Presentation Foundation (WPF)

1.3.10.1 HwndHost feature has been removed from WPF in the .NET Framework 4.5 Beta
The .NET Framework 4.5 Developer Preview included a WPF HwndHost redirection feature. However, this feature had several known issues and has been removed from the .NET Framework 4.5 Beta. It will not be included in any future releases.
To resolve this issue:
No workaround is available.

Thursday, November 29, 2012

Windows 8 Wireframe Templates for PowerPoint

If you don’t have access to the new Storyboarding features in Powerpoint, don’t worry. Andreas Wulf released a free set of Windows 8 Wireframe Templates for Powerpoint.

Using these templates, you can quickly put together a Windows 8 app layout and iterate on it. All elements in the set are based upon regular PowerPoint vector shapes, and are fully editable and customizable.

The wireframing set is available as a .pptx file (for PowerPoint 2007 or newer) that you can download using the link below:

Thanks Andreas!

Some screenshots:

Example grid page
Example grid page displaying item previews arranged in groups.

Example page displaying details
Example page displaying details for a single group with previews for each item in the group.

Example page displaying
Example page displaying one item in detail.

Example page displaying a list
Example page displaying a list of items and the details for the selected item.

Example of a Metro app
Example of a Metro app in snapped view state.

Collection of common UI controls
Collection of common UI controls (part 1): button, text box, list box, check box, radio button, toggle switch, etc.

List view
List view and charms bar.

App header
App header, app bar, and toast.

Wednesday, November 28, 2012

Testing Responsive Web Design

Last week I discovered the Responsive Web Design Testing Tool by Matt Kersley.

This tool has been built to help with testing your responsive websites while you design and build them. You can enter your website's URL into the address bar at the top of this page (not your browser's address bar) to test a specific page. The output will be rendered in different resolutions, giving you a quick overview of the design on different resolutions.

image

Tuesday, November 27, 2012

Installing the Web Deploy 3 publish components for Visual Studio 2010

I talked about some of the great features of Web Deploy 3 before. But how do you get the new publishing experience in Visual Studio 2010?

It took me some to figure out what software should be installed. You’ll need the following component:

  • Web publish 1.1 forVS 2010

The easiest way to get this software is by using the Web Platform Installer.

  • Download it here or open it if you already installed it before.

image

  • Go to the Products tab and search for Microsoft Web Publish 1.1 for Visual Studio 2010.

image

  • Click on Add and start the installation by clicking Install.

image

  • Once the installation has completed, you’ll see the new and improved Web Publishing wizard when you click Publish in a web application.

image

image

Monday, November 26, 2012

Getting DB2 .NET Provider to work on Windows 8(64bit)

With every new releases of the Microsoft OS, I’ll have to go through the same pain to get the DB2 providers working. IBM seems not able to release a driver that works out-of-the-box.

So what are the hacks this time to get it working?
  • Start with a normal installation of the DB2 client on your system(don’t forget to run as an administrator).
  • The installation will end successfully but  when you try to connect to a DB2 database, you’ll probably get an error similar to this one:

“sql1159 initialization error with db2 .net data provider reason code 7” 

  • Go to Start -> Programs -> Visual Studio -> Developer Command Prompt.
  • Open the prompt as an administrator
  • Add the following assemblies to the GAC using gacutil:
    • gacutil /if "C:\Program Files\IBM\SQLLIB\BIN\netf40\IBM.Data.DB2.dll"
    • gacutil /if "C:\Program Files\IBM\SQLLIB\BIN\netf40\IBM.Data.DB2.entity.dll"
    • gacutil /if "C:\Program Files\IBM\SQLLIB\BIN\netf40\IBM.Data.Informix.dll"
    • gacutil /if "C:\Program Files\IBM\SQLLIB\BIN\netf20\IBM.Data.DB2.dll"
    • gacutil /if "C:\Program Files\IBM\SQLLIB\BIN\netf20\IBM.Data.Informix.dll"
    • gacutil /if "C:\Program Files\IBM\SQLLIB\BIN\netf20\IBM.Data.DB2.entity.dll"
  • Go to the Windows  8 Start screen and start typing REGEDIT
  • Open the Registry Editor.
  • Go to HKEY_LOCAL_MACHINE -> SOFTWARE -> IBM -> DB2 –> InstalledCopies
  • Click on the folder InstalledCopies
    • Right Click -> New -> String Value
    • Set the value to 10.1.1.DEF.2(the name can be different depending on the DB2 version you tried to install, but you can find the name in the error message when you try to connect)
    • Right Click and Modify. Set the value to DB2COPY1 (your instance name may be different- this is the default)
  • Repeat the task for the registry entry for 10.1.1.DEF.4

Friday, November 23, 2012

IIS 8.0 Application Initialization module

I talked about the application pool ‘auto-start’ feature before. In IIS 8 it is renamed to Application Initialization module. Activating it allows you to enable the following capabilities:
  • Starting a worker process without waiting for a request (AlwaysRunning)
  • Load the application without waiting for a request (preloadEnabled)
  • Show a loading page while the application is starting
To enable these features
  • Set the startMode on the application pool  to AlwaysRunning.
<system.applicationHost>   
 <applicationPools>     
  <add name="DefaultAppPool" autoStart="true" startMode="AlwaysRunning" />   
 </applicationPools> 
</system.applicationHost>

  • Set preloadEnabled to true on the web application.

<system.applicationHost>   
 <sites>     
  <site name="Default Web Site" id="1">       
   <application path="/">         
    <virtualDirectory path="/" physicalPath="%SystemDrive%\inetpub\wwwroot" />       
   </application>       
   <application name="AppInit" applicationPool="DefaultAppPool" preloadEnabled="true">         
    <virtualDirectory path="/AppInit" physicalPath="c:\inetpub\wwwroot\appinit" />      
    </application>     
  </site>   
 </sites> 
</system.applicationHost>


Changing the startMode to AlwaysRunning will start the application pool and initialize your application the moment your IIS server is (re)started. So users that visit your site don’t have to wait because the worker process is already started.

By setting preloadEnabled to true, it starts loading the application within that worker process without waiting for a request.

More information:

Thursday, November 22, 2012

Free e-book: Testing for Continuous Delivery with Visual Studio 2012

Looking for a good book about testing with Visual Studio 2012?

Microsoft released the free Testing for Continuous Delivery with Visual Studio 2012 e-book.

“This book is aimed at test engineers, managers, developers, and folks interested in understanding the changing world of test. Over the last several years, software testing has changed a great deal. In the past, test plans were on paper, filed away and out of sight. Today they are—or can be with Visual Studio—living documents, as manual and automated tests are integrating into the test workflow supported by the test infrastructure.


Today you no longer have to set up physical boxes; instead you can set up and automate virtual environments composed of virtual machines to meet your testing environment needs. With Visual Studio and Team Foundation Server, the pain of dealing with a heterogeneous test infrastructure is reduced, the cost and effectiveness of testing a product is improved, and regression testing becomes cost effective instead of a nightmare.


Knowing how to test is important, but understanding how this new infrastructure is changing the business of testing and software delivery is critical. Today's businesses require nimble teams that can support continuous delivery and deal with updates and bugs in an agile fashion. It's what your customers have come to expect.
In this guide, we follow a team as they move from a conventional approach to testing towards one more suited to the needs of present-day development. We see how they address the costs and the pain of their old methods by adopting the testing infrastructure of Visual Studio 2012.”

image

Windows 8 System Info

I talked about uniquely identifying a Windows 8 device before. Last week I stumbled over this post by Rene Schulte.  In this post he creates the SystemInformation class. This class gathers some useful information about the current system and dumps it in a string:

using System;
using System.Globalization;
using System.IO;
using System.Net.NetworkInformation;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Text;
using System.Threading.Tasks;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Store;
using Windows.Devices.Enumeration;
using Windows.Devices.Input;
using Windows.Graphics.Display;
using Windows.Networking.Connectivity;
using Windows.Security.ExchangeActiveSyncProvisioning;
using Windows.Storage;
using Windows.System.Profile;
using Windows.System.UserProfile;
using Windows.UI.Xaml;

namespace Schulte.Xaml.Windows
{
public class SystemInformation
{
public static async Task<string> Dump(bool shouldDumpCompleteDeviceInfos = false)
{
var builder = new StringBuilder();
var packageId = Package.Current.Id;
var clientDeviceInformation = new EasClientDeviceInformation();

// Get hardware Id
var token = HardwareIdentification.GetPackageSpecificToken(null);
var stream = token.Id.AsStream();
string hardwareId;
using (var reader = new BinaryReader(stream))
{
var bytes = reader.ReadBytes((int)stream.Length);
hardwareId = BitConverter.ToString(bytes);
}

builder.AppendLine("***** System Infos *****");
builder.AppendLine();
#if DEBUG
builder.AppendLine("DEBUG");
builder.AppendLine();
#endif
builder.AppendFormat("Time: {0}", DateTime.Now.ToUniversalTime().ToString("r"));
builder.AppendLine();
builder.AppendFormat("App Name: {0}", packageId.Name);
builder.AppendLine();
builder.AppendFormat("App Version: {0}.{1}.{2}.{3}", packageId.Version.Major, packageId.Version.Minor, packageId.Version.Build, packageId.Version.Revision);
builder.AppendLine();
builder.AppendFormat("App Publisher: {0}", packageId.Publisher);
builder.AppendLine();
builder.AppendFormat("Supported Package Architecture: {0}", packageId.Architecture);
builder.AppendLine();
builder.AppendFormat("Installed Location: {0}", Package.Current.InstalledLocation.Path);
builder.AppendLine();
builder.AppendFormat("Store App Id: {0}", CurrentApp.AppId);
builder.AppendLine();
if (CurrentApp.LicenseInformation.IsActive)
{
var listingInformation = await CurrentApp.LoadListingInformationAsync();
builder.AppendFormat("Store Current Market: {0}", listingInformation.CurrentMarket);
builder.AppendLine();
}
builder.AppendFormat("Culture: {0}", CultureInfo.CurrentCulture);
builder.AppendLine();
builder.AppendFormat("OS: {0}", clientDeviceInformation.OperatingSystem);
builder.AppendLine();
builder.AppendFormat("System Manufacturer: {0}", clientDeviceInformation.SystemManufacturer);
builder.AppendLine();
builder.AppendFormat("System Product Name: {0}", clientDeviceInformation.SystemProductName);
builder.AppendLine();
builder.AppendFormat("System Sku: {0}", clientDeviceInformation.SystemSku);
builder.AppendLine();
builder.AppendFormat("System Name: {0}", clientDeviceInformation.FriendlyName);
builder.AppendLine();
builder.AppendFormat("System ID: {0}", clientDeviceInformation.Id);
builder.AppendLine();
builder.AppendFormat("Hardware ID: {0}", hardwareId);
builder.AppendLine();
builder.AppendFormat("User Display Name: {0}", await UserInformation.GetDisplayNameAsync());
builder.AppendLine();
builder.AppendFormat("Window Bounds w x h: {0} x {1}", Window.Current.Bounds.Width, Window.Current.Bounds.Height);
builder.AppendLine();
builder.AppendFormat("Current Orientation: {0}", DisplayProperties.CurrentOrientation);
builder.AppendLine();
builder.AppendFormat("Native Orientation: {0}", DisplayProperties.NativeOrientation);
builder.AppendLine();
builder.AppendFormat("Logical DPI: {0}", DisplayProperties.LogicalDpi);
builder.AppendLine();
builder.AppendFormat("Resolution Scale: {0}", DisplayProperties.ResolutionScale);
builder.AppendLine();
builder.AppendFormat("Is Stereo Enabled: {0}", DisplayProperties.StereoEnabled);
builder.AppendLine();
builder.AppendFormat("Supports Keyboard: {0}", IsKeyboardPresent());
builder.AppendLine();
builder.AppendFormat("Supports Mouse: {0}", IsMousePresent());
builder.AppendLine();
builder.AppendFormat("Supports Touch (contacts): {0} ({1})", IsTouchPresent(), new TouchCapabilities().Contacts);
builder.AppendLine();
builder.AppendFormat("Is Network Available: {0}", NetworkInterface.GetIsNetworkAvailable());
builder.AppendLine();
builder.AppendFormat("Is Internet Connection Available: {0}", NetworkInformation.GetInternetConnectionProfile() != null);
builder.AppendLine();
builder.AppendFormat("Network Host Names: ");
foreach (var hostName in NetworkInformation.GetHostNames())
{
builder.AppendFormat("{0} ({1}), ", hostName.DisplayName, hostName.Type);
}
builder.AppendLine();
builder.AppendFormat("Current Memory Usage: {0:f3} MB", GC.GetTotalMemory(false) / 1024f / 1024f);
builder.AppendLine();
builder.AppendFormat("App Temp Folder: {0}", ApplicationData.Current.TemporaryFolder.Path);
builder.AppendLine();
builder.AppendFormat("App Local Folder: {0}", ApplicationData.Current.LocalFolder.Path);
builder.AppendLine();
builder.AppendFormat("App Roam Folder: {0}", ApplicationData.Current.RoamingFolder.Path);
builder.AppendLine();
builder.AppendLine();

if (shouldDumpCompleteDeviceInfos)
{
var devInfos = await DeviceInformation.FindAllAsync();
//builder.AppendLine("CPU Info:");
//foreach (var devInfo in devInfos.Where(d => d.Name.ToLower().Contains("cpu")))
//{
// builder.AppendFormat("Name: {0} Id: {1} - Properties: ", devInfo.Name, devInfo.Id);
// foreach (var pair in devInfo.Properties)
// {
// builder.AppendFormat("{0} = {1}, ", pair.Key, pair.Value);
// }
// builder.AppendLine();
//}

builder.AppendLine();
builder.AppendLine("Complete Device Infos:");
foreach (var devInfo in devInfos)
{
builder.AppendFormat("Name: {0} Id: {1} - Properties: ", devInfo.Name, devInfo.Id);
foreach (var pair in devInfo.Properties)
{
builder.AppendFormat("{0} = {1}, ", pair.Key, pair.Value);
}
builder.AppendLine();
}
}

return builder.ToString();
}

public static bool IsTouchPresent()
{
return new TouchCapabilities().TouchPresent == 1;
}

public static bool IsMousePresent()
{
return new MouseCapabilities().MousePresent == 1;
}

public static bool IsKeyboardPresent()
{
return new KeyboardCapabilities().KeyboardPresent == 1;
}
}
}

Wednesday, November 21, 2012

ASP.NET Web API REST Guidance

ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework. Josh Reuben did a great job creating a guide of how to leverage Web API to construct a RESTful frontend API.

This guide contains the following topics:

A must read for every Web API developer!

Tuesday, November 20, 2012

New Visual Source Safe Upgrade Tool

Microsoft released a new version of the Visual Source Safe Upgrade tool. The tool provides a Wizard Based UI for upgrading Visual Source Safe repositories to Team Foundation Server 2012, 2010 or Team Foundation Service (http://tfs.visualstudio.com/)

It supports upgrading the following components from Visual SourceSafe to Team Foundation Server (TFS) version control:

  • Code projects
  • Files
  • Version history
  • Labels
  • User information

Documentation can be found at:

http://msdn.microsoft.com/en-us/library/ms253060.aspx

Download it from the Visual Studio Gallery:

http://visualstudiogallery.msdn.microsoft.com/867f310a-db30-4228-bbad-7b9af0089282

Monday, November 19, 2012

Team Foundation Server 2012 Illustrated Install Guide

Installing Team Foundation Server can be a daunting task. To help you in the process, Benjamin Day created an illustrated guide that walks you through the process of installing Team Foundation Server 2012 (TFS2012), the TFS2012 Build Service, System Center Virtual Machine Manager 2012, and TFS Lab Management.

image

You can download the install guide as a Word document and as a PDF or watch it online.

Friday, November 16, 2012

Need help to remember Visual Studio Shortcut Keys: IntelliCommand

For a developer being productive in it’s development environment is of the uppermost importance. One thing to make you more productive is knowing all(or some) keyboard shortcuts. Before I printed out the Visual Studio keybinding posters, but now I found a better alternative:   IntelliCommand.

From the Visual Studio Gallery:

“IntelliCommand - an extension for Visual Studio 2010 and 2012 which helps to find the short keys. It shows the help windows with all possible combinations when you press Ctrl or Shift or Alt or their combinations (hold it for about 2 seconds to see this window). Also it shows the list of possible combination when you press first combination of chord shortcut keys, like Ctrl+K, Ctrl+C (this combination comments selected text in editor).”

Intelli Command shows all available shortcut keys for combination of Control + Shift after couple seconds:

Ctrl+K was pressed. Visual Studio waits for second combination:

Team Foundation Services is released

Last week Microsoft announced the release of Team Foundation Service. The new url for the service is http://tfs.visualstudio.com.  Read more about it on the service web site here: http://tfs.visualstudio.com/en-us/home/news/.

I got a lot of questions about the pricing strategy for this product. Microsoft revealed some information about their pricing strategy but for the complete information about paid plans and services, you’ll have to wait until 2013.

At the moment Team Foundation Service includes a free usage plan with a robust set of features that make it quick and easy for individuals and lean teams to get started with this application lifecycle management (ALM) platform. The free plan includes support for up to 5 users, an unlimited number of projects, version control, work item tracking, agile planning tools, feedback management, and build (the last of which is still in preview).

In addition, MSDN subscribers at the Visual Studio Test Pro with MSDN, Visual Studio Premium with MSDN, and Visual Studio Ultimate with MSDN levels will have use of the service included as a subscription benefit. For the time being, anyone can sign up and use the service for free.

image

Thursday, November 15, 2012

ASP.NET MVC: The length of the string exceeds the value set on the maxJsonLength property.

Last week one of our users reported a bug that they got an exception back when loading a big set of data. When looking at the exception logs, we saw that the following InvalidOperation exception was thrown:

Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.

Some people suggested to set the maxJsonLength property in the web.config to a higher value, but this value is not used by ASP.NET MVC

<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="100000"/>
</webServices>
</scripting>
</system.web.extensions>


We solved the issue by creating our own Actionresult inheriting from the existing JsonResult class based on the information in this post:



public class LargeJsonResult:JsonResult
{
const string JsonRequestGetNotAllowed = "This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet.";

public LargeJsonResult()
{
MaxJsonLength = 1024000;
RecursionLimit = 100;
}

public int MaxJsonLength { get; set; }
public int RecursionLimit { get; set; }

public override void ExecuteResult(ControllerContext context)
{
if (context == null)
throw new ArgumentNullException("context");

if (JsonRequestBehavior == JsonRequestBehavior.DenyGet && String.Equals(context.HttpContext.Request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase))
throw new InvalidOperationException(JsonRequestGetNotAllowed);

var response = context.HttpContext.Response;
response.ContentType = !String.IsNullOrEmpty(ContentType) ? ContentType : "application/json";

if (ContentEncoding != null)
response.ContentEncoding = ContentEncoding;

if (Data != null)
{
var serializer = new JavaScriptSerializer { MaxJsonLength = MaxJsonLength, RecursionLimit = RecursionLimit };
response.Write(serializer.Serialize(Data));
}
}
}

Wednesday, November 14, 2012

Windows 8 Tiles: The tile template catalog

The Windows 8 ecosystems offers you a broad set of tiles to improve the user experience. I always forget the list of available templates so this one is for me; a link to the tile template catalog so I can never forget the list of available options: http://msdn.microsoft.com/en-us/library/windows/apps/hh761491.aspx.

The template catalog lists the tile templates available for use in a tile notification, with pictorial examples of each together with their XML content.

image

Note that when they are displayed on a computer set to a right-to-left (RTL) language, templates are flipped from their left and right descriptions here.

In the static or peek templates that display an image collection, the larger square image is not quite square; it is slightly wider than it is tall. If you supply a square image, the image will be scaled for width and slightly cropped on the top and bottom.

Tuesday, November 13, 2012

Reporting Services error: Maximum request length exceeded

Last week a colleague asked me to have a look at a Reporting Services problem. The reporting server returned the following error message when she tried to upload a report:

Error : There was an Exception running the extension specified in the config file –> maximum request length exceeded.

The problem started to occur after she added a large image to the report. By doing this the report size became too big and the report server started to complain that we are sending more data than it is configured to accept.

Fixing this is similar to every other web application, do this by changing the web.config. This config file can be found on the following path: C:\Program Files\Microsoft SQL Server\MSRS10_50.SQLEXPRESS\Reporting Services\ReportServer

  • Open the config file and find the following line:
    <httpRuntime executionTimeout = "9000" />
  • Add a maxRequestLength attribute in there to fix the problem:
    <httpRuntime executionTimeout = "9000" maxRequestLength="1000000" />
  • Restart IIS.

Monday, November 12, 2012

Show deleted items in Visual Studio Team Foundation Source Control

By default when you delete an item from TFS source control, it’s not really deleted. Instead it’s marked as deleted and no longer visible in source control but it’s not deleted from the TFS database. (If you really want to delete something from the database, you can use the TFS Destroy command.

But what if you want to “undelete” a deleted item? To allow this, we first have to show those deleted items in Source Control Explorer. Inside Visual Studio, go to “Tools-Options”, select “Source Control-visual Studio Team Foundation Server” and check the “Show deleted items in the Source Control explorer”.

image

Friday, November 9, 2012

Changing the WCF Data Service request headers

The WCF Data Service client component works great out-of-the-box. However for a project we wanted to send some extra header data which each request. On the server-side we could handle this by adding a custom WCF behavior on top of the data service, but on the client side this is not possible.

How can we do this on the client side?

The MSDN site brought the answer: http://msdn.microsoft.com/en-us/library/gg258441.aspx

The DataServiceContext exposes a SendingRequest event. By subscribing to this even we can add a new header to the request message before it is sent to the data service.

// Create the DataServiceContext using the service URI.
NorthwindEntities context = new NorthwindEntities(svcUri);

// Register to handle the SendingRequest event.
context.SendingRequest += new EventHandler<SendingRequestEventArgs>(OnSendingRequest);


The following method handles the SendingRequest event and adds an Authentication header to the request.



private static void OnSendingRequest(object sender, SendingRequestEventArgs e)
{
// Add an Authorization header that contains an OAuth WRAP access token to the request.
e.RequestHeaders.Add("Authorization", "WRAP access_token=\"123456789\"");
}

MSBuild Extension Pack–October 2012 Release

Good news for everyone who wants to get the most out of their build environment. A new release is available of the MSBuild Extension Pack.
This release contains around 40 new Tasks/ TaskActions.
Some information from the CodePlex site:
The MSBuild Extension Pack provides a collection of over 475 MSBuild Tasks, MSBuild Loggers and MSBuild TaskFactories.
A high level summary of what the tasks currently cover includes the following:

  • System Items: Active Directory, Certificates, COM+, Console, Date and Time, Drives, Environment Variables, Event Logs, Files and Folders, FTP, GAC, Network, Performance Counters, Registry, Services, Sound
  • Code: Assemblies, AsyncExec, CAB Files, Code Signing, DynamicExecute, File Detokenisation, GUID’s, Mathematics, Strings, Threads, Xml, Zip Files
  • Applications: BizTalk 2006 / 2009, Email, IIS6, IIS7, MSBuild, SourceSafe, SQL Server 2005, SQL Server 2008, StyleCop, Subversion, Twitter, Team Foundation Server, Visual Basic 6, Windows Virtual PC, WMI

The MSBuild Extension Pack is provided in two versions. The 3.5.* version supports the .Net Framework 3.5 and the 4.0.* version supports the .Net Framework 4.0.

Thursday, November 8, 2012

An update on runAllManagedModulesForAllRequests.

I talked about disabling the runAllManagedModulesForAllRequests setting in your web.config before. It seems that the story is a little bit more complex then I thought. Rick Strahl’s wrote a great article about some of the caveats of with the runAllManagedModulesForAllRequests in IIS 7/8.
He mentions that setting the runAllManagedModulesForAllRequests=”false”  has a different behavior as I originally expected. I expected that non-ASP.NET requests no longer passes through the ASP.NET Module pipeline. But that's not what actually happens.
Rick gave the following sample:
If you create a module like this:
<add name="SharewareModule" type="HowAspNetWorks.SharewareMessageModule"  />
by default it will fire against ALL requests regardless of the runAllManagedModulesForAllRequests flag. Even if the value runAllManagedModulesForAllRequests="false", the module is fired with unmanaged requests going through it.

So what is the runAllManagedModulesForAllRequests really good for? It's essentially an override for managedHandler preCondition. If you declare your handler in web.config like this:
<add name="SharewareModule" type="HowAspNetWorks.SharewareMessageModule" 
           preCondition="managedHandler" />
and then set runAllManagedModulesForAllRequests="false" your module only fires against managed requests. If you switch the flag to true, now your module ends up handling all IIS requests that are passed through from IIS.
 
So what do we need to remember?

You should always set the preCondition="managedHandler" attribute to ensure that only managed requests are fired on this module. But even if you do this, realize that runAllManagedModulesForAllRequests="true" can override this setting, so your module has to anticipate handling any kind of request.


Thanks Rick for this useful information!