Thursday, January 31, 2013

Sideloading prices: will this kill the winrt business model?

Last week I was reading this blog post by RockFord Lhotka. He talks about the cost of deploying a business application for Windows 8 using sideloading. Sideloading is the process of  installing a Windows 8 application without the need to put in the Windows 8 store. This is probably the most useful option when you want to get a company app to your users.

From his blog:

The short story with deployment is summarized in this table:

On Domain Not on domain
Windows RT n/a w/ key
Windows 8 n/a n/a
Windows 8 Pro w/ key w/ key
Windows 8 Enterprise yes w/ key

The “yes” designation means you can deploy to these devices at no additional cost for licensing. You will still need to figure out how to actually push the apps to the Windows 8 Enterprise computers. The options are the same as what follows where I discuss the “w/ key” designation.

The “w/ key” designation means you need to buy a $30 side-loading product activation key that is per device, and which is non-transferable. So to side-load apps on your Surface RT (for example) you need to buy a $30 key. These keys come in packs of 100, so the minimum price is $3000.

I was really shocked by this news. This means that you already have to spend a lot of money, just to have the right to install your application on a Windows 8 device. If you starts to take the deployment mechanism into account(and use the InTune add-in for System Center for example) the costs even increase more. Bedroefde emoticon

Rockford Lhotka gives the sample of deploying and running a Company Windows 8 app on 100 devices for 3 years will cost you around $23,000 extra to deploy a WinRT app just for this licensing! This kills the whole Windows 8 opportunity for company apps.

I think I would recommend to build a web application or WPF application instead…

Wednesday, January 30, 2013

WebDeploy error: System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.

When trying to deploy a web application from Visual Studio, it failed with the following error message:


This error message didn’t help much so I logged on to the server where I found the following error info in the Event log:


Client IP:

Content-Type: application/msdeploy


MSDeploy.VersionMin: 7.1.600.0

MSDeploy.VersionMax: 9.0.1631.0

MSDeploy.Method: Sync

MSDeploy.RequestId: 3e4d3744-90cf-4c95-85c9-28eb30970c3e

MSDeploy.RequestCulture: nl-BE

MSDeploy.RequestUICulture: en-US

ServerVersion: 9.0.1631.0

Skip: objectName="^configProtectedData$"

Provider: auto, Path:

A tracing deployment agent exception occurred that was propagated to the client. Request ID '3e4d3744-90cf-4c95-85c9-28eb30970c3e'. Request Timestamp: '8/01/2013 11:41:32'. Error Details:

System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.

   at System.Security.AccessControl.Win32.SetSecurityInfo(ResourceType type, String name, SafeHandle handle, SecurityInfos securityInformation, SecurityIdentifier owner, SecurityIdentifier group, GenericAcl sacl, GenericAcl dacl)

   at System.Security.AccessControl.NativeObjectSecurity.Persist(String name, SafeHandle handle, AccessControlSections includeSections, Object exceptionContext)

   at System.Security.AccessControl.NativeObjectSecurity.Persist(String name, AccessControlSections includeSections, Object exceptionContext)

   at Microsoft.Web.Deployment.FileSystemSecurityEx.Persist(String path, Boolean isFile)

   at Microsoft.Web.Deployment.SetAclProvider.Add(DeploymentObject source, Boolean whatIf)

   at Microsoft.Web.Deployment.DeploymentObject.Update(DeploymentObject source, DeploymentSyncContext syncContext)

   at Microsoft.Web.Deployment.DeploymentSyncContext.HandleUpdate(DeploymentObject destObject, DeploymentObject sourceObject)

   at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildrenOrder(DeploymentObject dest, DeploymentObject source)

   at Microsoft.Web.Deployment.DeploymentSyncContext.ProcessSync(DeploymentObject destinationObject, DeploymentObject sourceObject)

   at Microsoft.Web.Deployment.DeploymentObject.SyncToInternal(DeploymentObject destObject, DeploymentSyncOptions syncOptions, PayloadTable payloadTable, ContentRootTable contentRootTable, Nullable`1 syncPassId)

   at Microsoft.Web.Deployment.DeploymentAgent.HandleSync(DeploymentAgentAsyncData asyncData, Nullable`1 passId)

   at Microsoft.Web.Deployment.DeploymentAgent.HandleRequestWorker(DeploymentAgentAsyncData asyncData)

   at Microsoft.Web.Deployment.DeploymentAgent.HandleRequest(DeploymentAgentAsyncData asyncData)

Based on the UnauthorizedAccessException, I’m guessing that I forgot to configure some security settings in IIS. So let’s try to fix this…

  • Open the IIS Manager. Select the web site you want to deploy to on the left. On the Features view on the right look for the Management block:


  • Select IIS Manager Permissions and click on the Allow User… action in the Actions menu on the right.


  • The Allow User… dialog is loaded. If you have configured a specific account to manage web deploy select the IIS Manager radio button(otherwise choose the Windows radio button). Click on the Select… button to select a user.


  • Choose a user from the list and click OK.


  • Click OK again.


After doing this, the IIS Manager account (in this case WebDeployUser) can be used when you want to deploy through web deploy.

As a last step, we’ll have to give IIS the necessary rights to create folders and add files to the target location. So browse to the target folder and give the Local Service user ‘Full Control’ access rights.

That’s it…

Tuesday, January 29, 2013

WinRT: AppBar button values

WinRT gives you a lot of AppBar buttons out-of-the-box. These buttons can be found in the StandardStyles.xaml(don’t forget to comment them out if you want to use them) and are styled like this:

I wanted to create my own button and I was wondering where the value of the Content property(&#xE112) is coming from…

To find the related icon you’ll have to open the Character Map program & select the Segoe UI Symbol from the font list.


If you click on a specific character you see the value that is used inside the Content property(without the &#x at the beginning).


Monday, January 28, 2013

Gister: Create GitHub gists from within Visual Studio

For a long time I used Syntax Highlighter to embed code snippets in my blog posts. Last week I decided to switch to GitHub gists.

One tool that made my life a lot easier is Gister. Gister is a Visual Studio plugin that lets you push code snippets out to Gister will package the active file or, if one exists, the selection in that file, create the gist and copy the gist url into the clipboard.


Friday, January 25, 2013

Caliburn Micro: Problems binding an action to an element in a combobox

One of the cool features inside Caliburn.Micro is the support for Actions. Actions allow you to bind any UI event to a method on the ViewModel without the need of  Command binding.

Last week when building a Windows 8 application I couldn’t get it working for a combobox containing a list of buttons. I wanted to execute some code once a button inside the combobox was clicked.

But it didn’t work as expected. The problem was related to the fact that a ComboBox uses a FlyOut for it’s rendering which its not part of the Visual Tree. So Caliburn.Micro wasn’t able to walk the visual tree and detect the ViewModel instance that was bound to the View through the DataContext. Instead I had to give Caliburn.Micro an extra hint by using Action.TargetWithoutContext;

Thursday, January 24, 2013

SQL Server 2012: Nice features for developers

I finally found some time to have a look at SQL Server 2012. There is still a lot to discover but I already want to highlight 2 great new features:
Sequence Objects

It’s a feature I already know from Oracle, but now SQL Server finally supports Sequence Objects too. A sequence object generates sequence of unique numeric values. It’s a nice alternative if you don’t want to use Identity fields or want to get a unique number up front.

Here is a sample that creates a sequence that starts with 1 and gets incremented by 1. The minimum value is 0 and maximum value is 100. If you go higher that 100 an error is thrown(if you don’t want this you can change this by specifying ‘cycle’ instead of  ‘no cycle’.

To increment the value we need to call the statement below:


Another nice features that got added to SQL Server 2012 is the built-in support for pagination. Before I had to combine “ROW_NUMBER and “TOP” to get a subset of results. Now I can use  “OFFSET” and “FETCH’ commands to do pagination.

To skip the first 10 results and take the next 10 results from a Products table, I can write the following query:

Wednesday, January 23, 2013

Great Scrum introduction: “SCRUM: The Story of an Agile Team”

Scrum is one of the most popular Agile methodologies. However implementing Scrum is hard and most organizations end up with a ‘Scrum-but’ result.

In my opinion there isn’t one correct way to implement Scrum instead it’s more like a journey were you have to try some of the practices and find out what works(for your team) and what not.

On NetTuts I found a great tutorial where Patkos Csaba shares his experiences implementing Scrum.


A must read for every (would be)Scrum Master!

Tuesday, January 22, 2013

OData: include multiple children in a result set

Last week I got the following question:

“I have an OData service that returns a set of Portfolios. Each portfolio also has a list of Sectors, a list of Technologies and a list of Customers. How can I query this OData feed and get all the results back in one request?”

To achieve this we need to use the Expand() keyword

Here is a sample how to do this in Linq;

And here is the resulting url that returns the same results:


Monday, January 21, 2013

Windows Azure Virtual Machines: The operation cannot be performed because the virtual machine is faulted.

When creating a new Virtual Machine on Windows Azure, it didn’t start as expected. Instead I ended up with the following message on the Windows Azure portal:


When I tried to start the Virtual Machine again I immediately got the following error message back:


Although I have no clue why it failed, I was able to resolve the problem by resizing the VM.

Friday, January 18, 2013

WinRT: Something went wrong with Share. Try again later.

Last week I was happily implement the Share charm in a Windows 8 application, when it suddenly started to fail. Every time I clicked on the share button, no list of apps was shown. Instead I got the following message:

Something went wrong with Share. Try again later.

OK, I thought, probably I made some mistake, so I removed my last changes but no luck… Bedroefde emoticon No matter what I tried I couldn’t get the Share charm working again.

So what happened?

I discovered that if you debug your Search contract code,  it can result in system-wide shutdown of the service, meaning that no Windows Store app can share any content with other apps anymore. Typically, this happens when you stop debugging (in Visual Studio) while in DataTransferManager’s DataRequested event handler.

I found a fix on Andrej Tozon’s blog: restart the Explorer.exe process.

Here are the steps in case you don’t have any clue how to do this:

  • Open Task Manager
  • Select the Details tab
  • Find Explorer.exe (easiest to sort by Name)
  • End Task (button in right lower corner will do the job).
  • Select File –> Run new task
  • Type Explorer.exe in the input box
  • Press OK (and taskbar is back)

That should to the trick…

Thursday, January 17, 2013

OData Service for Team Foundation Server v2 Beta

Last week Microsoft released a beta of the OData Service for Team Foundation Server v2 along with a sample Windows Store application

The purpose of this service is to help developers work with data from Team Foundation Server on multiple device types (such as smartphones and tablets) and operating systems. OData provides a great solution for this goal, and has been embraced by numerous developers for building great device-specific applications. OData is accessible from any device and application stack which supports HTTP requests.

The OData service interacts directly with the TFS client object model, and will work with CodePlex, Team Foundation Server 2010 and Team Foundation Server 2012.

Read more about it here:

And download the bits here:

Wednesday, January 16, 2013

Visual Studio Extensibility: Configure Custom Tool in an ItemTemplate

Last week I created a Visual Studio custom tool to encrypt configuration files(more information about the process here and here). To simplify the usage and improve the discoverability I also created a custom Item Template.

But how can I automatically set this custom tool when a new item is created?
  • Open the .vstemplate-file.
  • Add a WizardExtension-node to the XML file:
  • Afterwars specify a CustomTool attribute on the ProjectItem:

Tuesday, January 15, 2013

WinRT: Check if your app is connected to the Internet

In almost every mobile application I’m building, offline support is a must have. So one of the things I always have to do is check if an Internet connection is available.

To help me remember this, a small code snippet that does the job:

Monday, January 14, 2013

Flat management structures: how it could work.

As a consultant I visit lots of different organizations each with their own management structure. Most of the time there is only one constant; a big hierarchy of managers who manage managers who manage managers who manage the working bees(probably I missed some management layers in between, but you get the idea…).

I always believed that a flatter organizational structure benefits the whole company(and creates less overhead). But I didn’t see a lot of examples in the wild. 2 successful organizations who took this to the extreme are GitHub and Valve(they have no managers at all!).

Are you interested in how they did this? Have a look at Valve’s handbook for new employees:


And watch this presentation by Zach Holman, one of the founders of GitHub:

Friday, January 11, 2013

WPF ChildWindow

I always wondered what could be the use of the ChildWindow in WPF? Last week I discovered a good reason to use it.
When you create a new window from inside your application, like in this example:
var dialog = new MyDialog();

If you press Alt-tab when the dialog is open, and you come back to the application pressing Alt-tab again, the main window will be shown but not the dialog. The reason is that the dialog has not been declared as owned by the main window.

I found a solution on CodeProject mentioning to set the owner of the Dialog window to the MainWindow like this:

public MyDialog()

 this.Owner = App.Current.MainWindow;

An alternative solution can be found in the Extended WPF Toolkit which contains a ChildWindow class. This class offers the same behavior without the extra code.


Thursday, January 10, 2013

Windows Azure Active Directory:Access control & Core Directory for free!

One of the most complex parts of the whole cloud story is Identity Management and Access Control. To help you master this complexity Microsoft released Windows Azure Access Control(ACS) as one of it first cloud services. Today ACS has evolved to Windows Azure Active Directory, an Active Directory solution built for the cloud.

Just before the year ending Microsoft announced that two key features of Windows Azure Active Directory became available at no charge:

  • Access control provides centralized authentication and authorization by integrating with consumer identity providers, such as Facebook, or using on-premises Windows Server Active Directory. By having Access Control available you can create a single application that can allow users to login with both their Organizational Credentials stored in Windows Azure AD or Windows Server AD, or to login in using popular consumer service identity services like Microsoft Account, Facebook, Google, or Twitter. Historically, Access Control has been priced based on the number of transactions.
  • Core Directory & Authentication enables capabilities such as single sign-on, user and group management, directory synchronization and directory federation.

Wednesday, January 9, 2013

Windows Azure: streaming videos from blob storage

Last week I discovered a nice feature of Windows Azure Blob storage. When you use Blob storage, you can change the API version. In the  2011-08-18 version of the Windows Azure Blob service, Microsoft  made some changes to improve browser download and streaming for some media players.

Before when you tried to play a video from blob storage, you had to download the whole file before you could start playing it. Starting from the 2011-08-18 version, you can do partial and pause/resume downloads on blob objects. The nice thing is that your client code doesn’t have to change to achieve this.

The only problem is that you have to set the version of the Blob storage(more info here).

I couldn’t find an easy way to specify the version, so in the end I wrote a small program:

var cloudStorageAccount = CloudStorageAccount
.Parse("DefaultEndpointsProtocol=https;AccountName={your account name};AccountKey={your account key}");

var client = cloudStorageAccount.CreateCloudBlobClient();
var prp = client.GetServiceProperties();

client.SetServiceProperties(new ServiceProperties()
DefaultServiceVersion = "2011-08-18",
Logging = prp.Logging,
Metrics = prp.Metrics

Tuesday, January 8, 2013

NHibernate: Get distinct results when using the QueryOver API

In a project we had the following NHibernate query code:
var decisions= session.QueryOver<Decisions>()
       .Where(a => a.Idproject == this.Id)
       .Fetch(a => a.DecisionMakers)

What’s important here is the Fetch() statement. The Fetch().Eager statement will not only load the Decisions but also the related Decision Makers when we execute this query(probably by using a join).

The problem was that when a decision has more then one decisionmaker, we get the same decision back multiple times(one time for each decision maker that was found).

To solve this, you have to tell NHibernate to filter the results by calling .TransformUsing(Transformers.DistinctRootEntity).

Monday, January 7, 2013

AES encryption error

When implementing symmetric encryption in an application, I had some trouble specifying the correct key size.
public string Encrypt(string plainText, string key = KEY, string IV = IV)
 byte[] encrypted;
 // Create an Aes object
 // with the specified key and IV.
 using (Aes aesAlg = Aes.Create())
  aesAlg.Key = System.Text.Encoding.Default.GetBytes(key);
  aesAlg.IV = System.Text.Encoding.Default.GetBytes(IV);

  // Create a decrytor to perform the stream transform.
  ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV);

  // Create the streams used for encryption.
  using (var msEncrypt = new MemoryStream())
  using (var csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
   using (var swEncrypt = new StreamWriter(csEncrypt))
                       //Write all data to the stream.
   encrypted = msEncrypt.ToArray();

 // Return the encrypted bytes from the memory stream.
 return Convert.ToBase64String(encrypted);

I tried some possible key values but I always got the following error back:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Security.Cryptography.CryptographicException: The specified key is not a valid size for this algorithm.

   at System.Security.Cryptography.AesCryptoServiceProvider.set_Key(Byte[] value)

   --- End of inner exception stack trace ---

   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Reflection.Assembly.CreateInstance(String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
So what is a correct length for the key and vector when using AES encryption?
For the key and vector specify a 16 characters long value.

Friday, January 4, 2013

Responsive Web Design: Responsinator

Always looking for some useful tools to help me build responsive web applications, I discovered

From the site:

What is The Responsinator?

The Responsinator helps website makers quickly get an indication of how their responsive site will look on the most popular devices. It does not precisely replicate how it will look, for accurate testing always test on the real devices.

We recommend using Chrome on OSX 10.7+ with scroll bars set to "when scrolling" (System Preferences › General › Show scroll bars › "when scrolling"). This means the device widths aren’t affected by scroll bars.

Update: append &scroll=ext to move the scroll bars outside of the device frame.

Using it is simple, enter the url of your application in the top bar and click Go.


The website will be loaded on a range of devices(or better said in an iframe with a similar size):


Thursday, January 3, 2013

RavenDb: Delete al documents from a specific type

Last week I was looking for a way to delete all documents of a specific type from the database. For example you want to remove all your Orders from the database.

I started implementing this by loading all documents and delete them one by one. But this was a rather inefficient solution, so I started to look at some alternatives.

After some attempts, I ended up with the following code:

var documentName="Orders";

new IndexQuery { Query = "Tag:" + documentName },
allowStale: true

Clean, simple AND efficient!

Wednesday, January 2, 2013

RavenDB: Change the primary key convention

Every document in RavenDB should have a unique identifier. By default it searches for properties named Id. If it couldn’t find such a property an unique identifier is created for you behind the scenes(but is not available through a property on your object).

But what if you don’t like this convention?

For example what if you want to call your identifier properties ‘key’ instead of ‘id’. Changing this convention is easy in RavenDB:

var documentStore = new EmbeddableDocumentStore
DataDirectory = "App_Data",
UseEmbeddedHttpServer = true

var store= documentStore.Initialize();

store.Conventions.FindIdentityProperty = prop =>