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!

Wednesday, November 7, 2012

Click Once certificates stopped working after a Windows Update

At a customer we are using Click Once to deploy our Windows Client Applications. These applications are signed by a certificate to improve security and differentiate between the available environments(we’ve created a different certificate for each environment).

This all worked fine for years until 2 weeks ago. Developers started to complain that they could no longer publish their application using these certificates. They got the following error in Visual Studio:

Error     4          An error occurred while signing: Failed to sign bin\x86\Acceptatie\app.publish\\setup.exe. SignTool Error: The signer's certificate is not valid for signing.

SignTool Error: An error occurred while attempting to sign: bin\x86\Acceptatie\app.publish\\setup.exe   AppName

The certificates were still valid, their were not revoked or expired, the root certificate was available and trusted… To make it even stranger, the problem didn’t occur on all systems. On my system everything still worked normally. Until a few days later, I got the same problem?!

What changed on  my system that could have caused this issue? We noticed that the problems started to occur after installing a specific Windows Update.

This piece of information brought us to the following blog post(rsa keys under 1024 are blocked) containing this:

To further reduce the risk of unauthorized exposure of sensitive information, Microsoft has created a software update that will be released in August 2012 for the following operating systems: Windows XP, Windows Server 2003, Windows Server 2003 R2, Windows Vista, Windows Server 2008, Windows 7, and Windows Server 2008 R2. This update will block the use of cryptographic keys that are less than 1024 bits.
Some issues that you may encounter after applying this update may include:

  • Error messages when browsing to web sites that have SSL certificates with keys that are less than 1024 bits
  • Problems enrolling for certificates when a certificate request attempts to utilize a key that is less than 1024 bits
  • Creating or consuming email (S/MIME) messages that utilize less than 1024 bit keys for signatures or encryption
  • Installing Active X controls that were signed with less than 1024 bit signatures
  • Installing applications that were signed with less than 1024 bit signatures (unless they were signed prior to January 1, 2010, which will not be blocked by default).

To prepare for this update, you should determine whether your organization is currently using keys less than 1024 bits. If it is, then you should take steps to update your cryptographic settings such that keys under 1024 bits are not in use.

We had a second look at the certificates we were using and we noticed that although the certificate itself was using a 1024bit key, the root certificate we used to create these certificates was only 512bit. This made the whole certificate chain invalid.

If only we had noticed this article sooner…

Tuesday, November 6, 2012

Get the table size in SQL Server

Last week I noticed that our TFS database size was getting out-of-control. So I decided to have a look at what tables consumed the most disk space.

SQL Server makes this easy by providing a built-in stored procedure that shows the size of a table, including the size of the indexes:

sp_spaceused ‘Tablename’

A sample:

image

Monday, November 5, 2012

Windows Azure Poster

Looking for a new bedroom poster, or you just want to have a nice overview of all the components of Windows Azure?

Microsoft released the Windows Azure Poster.

image

Friday, November 2, 2012

Callisto: A control toolkit for Windows 8 XAML applications.

Building Windows 8 applications can be hard, there is a lot of stuff you need to implement to pass the Application Certification process. So every tool,framework or library that can help you save some time and focus on the application experience itself is more then welcome.

Calypso

One of these libraries is Callisto. If we look on the project page on GitHub, we’ll find following information:

What Is It?

Callisto is a library for use in Windows 8 XAML applications (aka Metro style apps). The XAML framework in Windows.UI.Xaml is great, but has some functionality that isn't provided in-the-box in a few controls and APIs. Callisto provides added functionality on top of the XAML UI framework for Windows.

What's In It?

So far Callisto includes:

  • Flyout - a primitive that includes positioning and 'light dismiss' logic
  • NumericUpDownControl - a "spinner" control for numeric values
  • WatermarkTextBox - derivative of TextBox that adds only the functionality of providing a default text 'hint' in the text input area if no text exists
  • FlipViewIndicator - providing some hinting UI to the user where they are in the navigation of items within a FlipView
  • SettingsManagement API making it easier to do app-wide registration of SettingsFlyout elements
  • Menu - primarily to be used from AppBar, contains the base for providing, well, a Menu
  • MenuItem - an item for a menu, including separators and contains the command point for the menu item
  • SettingsFlyout - an item to create a custom settings pane UI
  • Rating - a ratings control for Metro UI
  • LiveTile - an in-app tile experience to give you animated or 'live' tiles
  • Tilt - an effect to provide the tilt experience when clicked on edges/corners
  • OAuth helpers - a set of helpers to create OAuth 1.0 signatures/headers for those sites that hate OAuth 2.0 :-)
  • BooleanToVisibilityConverter - a converter to well, convert boolean to visibility, very common use
  • LengthToBooleanConverter - a converter to examine a string length to convert to boolean (simple validation helper)
  • RelativeTimeConverter - a converter to show time as relative string, i.e., 'about an hour ago'
  • Extensions - some extension method helpers (i.e., bind html content to a WebView)

Probably the easiest way to start using it, is by installing it through NuGet. Also have a look at the project wiki.

(I only used the SettingsFlyout so far, so if you used other parts of the toolkit and want to share your experience, let me know…)

Thursday, November 1, 2012

Setting up sliding sessions in Windows Identity Foundation(WIF)

By default a WIF security token is only valid for a certain time. However this token does not work with a sliding expiration out-of-the-box. This means that, no matter if the users is actively using the application or not, once the time interval has expired, the token is invalidated and the user has to login again.
Although this seems logical from a security standpoint, it’s not very user friendly. Users expect that as long as they are using the application, their authentication session remains valid.
So how can we achieve sliding expiration in WIF?
public class SlidingAuthenticationModule : SessionAuthenticationModule
{
   
}
  • Register for the SessionSecurityTokenReceived event in the constructor:
   public SlidingAuthenticationModule
   {
      this.SessionSecurityTokenReceived += SessionSecurityTokenReceived; 
   }

   void SessionSecurityTokenReceived(object sender, SessionSecurityTokenReceivedEventArgs e)
   {
      
   }
  • Add code to the event handler to implement the sliding expiration:

void SessionSecurityTokenReceived(object sender, SessionSecurityTokenReceivedEventArgs e)
{ 
 var sessionToken = e.SessionToken;
    SymmetricSecurityKey symmetricSecurityKey = null;

    if (sessionToken.SecurityKeys != null)
     symmetricSecurityKey = sessionToken.SecurityKeys.OfType<SymmetricSecurityKey>().FirstOrDefault();

 if (sessionToken.ValidTo > DateTime.UtcNow)
    {
  var slidingExpiration = sessionToken.ValidTo - sessionToken.ValidFrom;

  e.SessionToken = new SessionSecurityToken(
                    sessionToken.ClaimsPrincipal,
                    sessionToken.ContextId,
                    sessionToken.Context,
                    sessionToken.EndpointId,
                    slidingExpiration,
                    symmetricSecurityKey);

     e.ReissueCookie = true;
    }
    else
    {
        var sessionAuthenticationModule = (SessionAuthenticationModule) sender;
        sessionAuthenticationModule.DeleteSessionTokenCookie();
     e.Cancel = true;
 }
}

  • Inside your web.config, replace the default SessionAuthentication module with the new module you’ve created:

<modules>
   <add name="SessionAuthenticationModule" type="SlidingAuthenticationModule" preCondition="managedHandler"/>
</modules>