Skip to main content

Posts

Showing posts from January, 2016

Angular 1.x to Angular 2 Quick Reference

A little bit short on time today. So I only want to share this great link that compares the syntax between Angular 1.x and Angular 2: http://blogs.msmvps.com/deborahk/angular-1-x-to-angular-2-quick-reference/ As I’m struggling a little bit with the new syntax, this is a great help when you couldn’t remember the exact code required. You can always fallback to the official documentation , but this Quick Reference is a lot shorter and easier to use…

TFS 2013 XAML Builds: BuildDetail variable no longer available

After upgrading a customer from TFS 2012 to TFS 2013, we couldn’t access the BuildDetail property anymore inside our XAML build process template. Instead we got the following error message: Error 102 Compiler error(s) encountered processing expression "BuildDetail.DropLocation". 'Microsoft.TeamFoundation.Build.Client.BuildDetail' is not accessible in this context because it is 'Friend'. This is a breaking change when upgrading from TFS 2012 to TFS 2013. Luckily it is not hard to solve: Open your XAML build process template Add a Variable on the Variables tab Choose IBuildDetail as type Name it BuildDetail Drag a GetBuildDetail activity inside your workflow Set the Result property to the BuildDetail variable Now you can access the same information as before…

Entity Framework Async: The source IQueryable doesn't implement IDbAsyncEnumerable<>

While investigating an Entity Framework issue, I stumbled over the following exception The source IQueryable doesn't implement IDbAsyncEnumerable<VLM.PlattelandsLoket.Domain.Views.Codes.CodeValueView>. Only sources that implement IDbAsyncEnumerable can be used for Entity Framework asynchronous operations. For more details see http://go.microsoft.com/fwlink/?LinkId=287068 . What’s causing this error? Entity Framework 6 introduced async support through a set of extension methods. These extension methods are defined on IQueryable and IEnumerable but actually expect an IDbAsyncEnumerable implementation behind the scenes  to work. When you try to use one of these extension methods on a LINQ query that isn’t an Entity Framework query, you end up with the error message above. I have to say I’m not a big fan of this approach, it sounds like a ‘leaky abstraction’ to me. What do you think? Code smell or not?

.NET 4.5 Bug: Either ErrorMessageString or ErrorMessageResourceName must be set, but not both

When running an ASP.NET application on top of .NET 4.5, we encountered the following error: Either ErrorMessageString or ErrorMessageResourceName must be set, but not both The strange this was that we only noticed the issue on our test environment. On our local machine the application worked fine. Luckily an explanation was found on the following blog: http://gunnarpeipman.com/2015/02/either-errormessagestring-or-errormessageresourcename-must-be-set-but-not-both/ It seems that this is a bug in .NET 4.5, as we had .NET 4.6 running on our local machine, it explained that we couldn’t reproduce the issue on our local dev machines. As a workaround, you can follow the suggestion as mentioned in the post. Add an ‘ErrorMessage=null’ property to your Data Annotation:

MultipleActiveResultSets–what is it and should I use it?

On a project I had to review, I saw that one of the developers had enabled MultipleActiveResultSets(MARS) in the connection string.  "Data Source=MSSQL1;Initial Catalog=AdventureWorks;Integrated Security=SSPI; MultipleActiveResultSets=True "; When I asked if he was aware that it was enabled and asked the reasoning behind it, the answer was a blank stare: He just copied the connectionstring over from another project but had no idea why this setting was there. MARS was introduced in SQL Server 2005 and enable the possibility to maintain multiple active statements in one connection. This enables the following possibilities: Applications can have multiple default result sets open and can interleave reading from them. Applications can execute other statements (for example, INSERT, UPDATE, DELETE, and stored procedure calls) while default result sets are open. I see it most of the time in combination with Entity Framework when someone...

NuGet: Powershell script to set ‘Build Action’ property of files to ‘Content’

One of the nice things you can do with NuGet is to trigger a Powershell script (Install.ps1) when the NuGet package is installed or removed. From the documentation : A package can include PowerShell scripts that automatically run when the package is installed or removed. NuGet automatically runs scripts based on their file names using the following conventions: Init.ps1 runs the first time a package is installed in a solution. If the same package is installed into additional projects in the solution, the script is not run during those installations. The script also runs every time the solution is opened (Package Manager Console window has to be open at the same for the script to run). For example, if you install a package, close Visual Studio, and then start Visual Studio and open the solution with Package Manager Console window, the Init.ps1 script runs again. Install.ps1 runs when a package is installed in a project. ...

TFS 2015 - Release Manager Workflow Migrator

The ALM rangers never sleep. Now they have created a Release Manager Workflow Migrator: Looking to export a Release Management agent based deployment pipeline so that it can be reused in the Release Management service in Visual Studio Team Services (VSTS)? We have released a migration tool and associated guidance as an open source project, allowing you to use “as is” or contribute to the project. If a Pull Request shows up at the door for the source or documentation, it will definitely be considered. So if you are using Release Manager today and want to switch to the new Release Management service in VSTS, this will be a great help! More information: https://github.com/ALM-Rangers/Migrate-assets-from-RM-server-to-VSTS

Goodbye Azure Storage Explorer. Welcome Microsoft Azure Storage Explorer

For years I’m a happy user of the free Azure Storage Explorer . It makes it really easy to work with Azure Storage Tables, Queues and Blobs. Last week I discovered that Microsoft created their own tool with the original name ‘Microsoft Storage Explorer’ . The list of features is not as large but it has one compelling advantage; it’s a cross-platform tool available for both Windows, Linux and Mac. I’m certainly gonna give it a try…

Create your Azure Automation runbooks in a graphical way

Automation is a key piece in creating and maintaining your Azure environment. This month, Microsoft introduced a graphical tool and programming model to author and manage your automation scripts. So you don’t have to be a Powershell guru to start using the full power of Azure Automation.  Simply insert activities from the library to the canvas, link them together into a workflow, and configure the properties in order to create useful runbooks that automate your IT processes.  More information: https://azure.microsoft.com/en-gb/blog/azure-automation-graphical-and-textual-runbook-authoring/

Embed fonts in your web page using Data URI

In web applications you can embed images into a html page by base64 encoding an image and add it to the css on your page by using Data URI. Data URI is just a URI scheme that provides a way to include data in-line. Usage is simple, you create an ASCII string format representation from your binary data using Base64 encoding. The generated string is then stored in the css. Instead of using an URI to an image, you use the Data URI instead. The format of this URI looks like this: data:[<mediatype>][;base64],<data> An example of an encoded image looks like this: This is nothing new, but did you know that you can do the same thing for fonts?

If you have too many dependencies it’s time for something else

I’m a big fan of the Inversion of Control(IoC) pattern and how Dependency Injection(DI) frameworks can help you implement this pattern.  IoC was really a gamechanger to me and had a lot of impact on the way I build and architect my applications. Note: As I’m doing more and more functional programming, the need to use a DI framework is going away, but that’s something to discuss in another blog post Unfortunately something I see a lot in applications that use a DI framework is something I call “dependencies diarrhoea”. Let’s have a look at an example ASP.NET MVC controller to illustrate the problem: So what’s the problem here? Without even looking at the full implementation, it should be clear that this class is violating the ‘Single Responsibility Principle’ and is doing too much in one class. This not only makes it harder to reason about this class, but also makes it a lot harder to test. There is no fun in mocking out lots of dependencies just to test a small piece ...

Great Chrome extension–DOMListener

When building web applications using frameworks like Angular, React, and so on, there is always a lot of magic happening behind the scenes. This is all great until the moment it doesn’t work… One tool that helped me a lot in investigating what’s going on inside the browser, is the DOMListener Chrome extension : DOMListener is a simple tool that provides convenient interface for observing DOM changes (node removal and addition, attribute and text modifications). Events can be filtered with ease, affected nodes can be highlighted with a single click.

MSB4175: The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Build.Tasks.v12.0.dll".

After upgrading to TFS 2015, projects started failing to build on the (new) build server with the following error message: : D:\Build\Sources\Source\App\.nuget\nuget.targets(71,9): error MSB4175: The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Build.Tasks.v12.0.dll". Could not load file or assembly 'file:///C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Build.Tasks.v12.0.dll' or one of its dependencies. The system cannot find the file specified. We discovered that the issue was caused by the fact that we had configured a new build server with only Visual Studio 2013 and 2015 installed. On the old build server we had Visual Studio 2012 and 2013. As this project was created in VS 2012, it was looking for the Microsoft.Build.Tasks.v12.0.dll file in C:\Windows\Microsoft.NET\Framework64\v4.0.30319 folder. However in Visual Studio 2013 this file is no longer th...

Using a TransactionScope with async/await

Maybe you didn’t know but the System.Transactions.TransactionScope object in .NET doesn’t play nice together with the async/await syntax. As long as all the code inside the TransactionScope is executed on the same thread, there is no issue. But when you start combining it with async/await you get into trouble. The following code doesn’t work in .NET 4.5: Whenyou try to execute this code, it will fail with the following error: System.InvalidOperationException : A TransactionScope must be disposed on the same thread that it was created. A fix is available in .NET 4.5.1 but requires some code changes. There is a new enumeration TransactionScopeAsyncFlowOption that can be provided in the TransactionScope constructor. Here is the fixed code: