Skip to main content

Posts

Showing posts from January, 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

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: User: Client IP: 10.1.210.31 Content-Type: application/msdeploy Version: 9.0.0.0 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.AccessCon

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).

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 http://gist.github.com . 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.

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;

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: Pagination 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’ comm

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!

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: http://odatasample/Portfolio()?$expand=Sectors,Technologies,Customers

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.

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… 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 (easi

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: http://blogs.msdn.com/b/briankel/archive/2013/01/07/odata-service-for-team-foundation-server-v2.aspx And download the bits here: http://www.microsoft.com/en-us/download/details.aspx?id=36230

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:

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:

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(); dialog.ShowDialog() 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() { InitializeComponent(); 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.

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 Co

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(

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) .Eager .List() 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) .

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. swEncrypt.Write(plainText); } encrypted = msEncrypt.ToArray(); } } // Return the encrypted bytes from the memor

Responsive Web Design: Responsinator

Always looking for some useful tools to help me build responsive web applications, I discovered Responsinator.com . 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):

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"; session.Advanced.DatabaseCommands.DeleteByIndex("Raven/DocumentsByEntityName", new IndexQuery { Query = "Tag:" + documentName }, allowStale: true ); Clean, simple AND efficient!

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 => { return prop.Name .Equals("key",StringComparison.InvariantCultureIgnoreCase); };