Wednesday, May 31, 2017

The Module DLL C:\WINDOWS\system32\inetsrv\aspnetcore.dll failed to load. The data is the error.

After upgrading to the Anniversary Update of Windows 10, all applications on my local IIS no longer work and return a 503 error instead. When looking inside IIS I noticed that my Application pools were stopped but after restarting them, they stopped when the first new request arrives.

Inside the Windows Event Viewer I noticed the following error message:

The Module DLL C:\WINDOWS\system32\inetsrv\aspnetcore.dll failed to load.  The data is the error.

To fix it, I had to repair the installation of Microsoft .NET Core 1.0.1 – VS 2015 Tooling Preview 2:

  • Go to “Programs and Features”
  • Search for .NET Core

image

  • Select Microsoft .NET Core 1.0.1 – VS 2015 Tooling Preview 2 from the list
  • Click on Change and choose Repair

image

Tuesday, May 30, 2017

TFS–View Test Results for your Test Cases

I had a hard time yesterday finding out how I could see what Test Results are available for specific Test Cases.

In case I ever need it again(or someone else is as bad in finding it’s way through the TFS interface as me), here are the steps:

  • Open the TFS web portal and go to a specific Team Project.
  • Go to the Test Tab

image

  • Select a Test plan from the dropdown on the left and click on the Test suite that contains your test cases

image

  • On the right you see the list of available test cases

image

  • Click on the Show/Hide details button in the far right corner image
  • A detail pane is shown on the right

image

  • Click on the ‘Test case’ text next to the Pane and change it to ‘Test results’

image

Monday, May 29, 2017

TFS–How to see the executed commands and parameters

TFS keeps track of an activity log of all recent activities. This information is stored in 2 tables inside Tfs_Configuration and Tfs_collectionname called tbl_Command and tbl_Parameter. These tables keep a record of every single command that every single user has executed against TFS for the last 14 days(!).

So if you want to know which query is used to execute a specific action, it’s not that hard to find it through the Activity log.

image

If you don’t like to open SQL Server Management studio, you can also browse to the ‘hidden’ management pages at http://<tfsurl/_oi

image

Note: You can only access these pages when you do it directly from your TFS application server

When you click on the … next to the command you can see the related details

image

image

Friday, May 26, 2017

Using RyuJIT, the next generation JIT compiler for .NET

RyuJIT is the next generation Just-In-Time (JIT) compiler for .NET. It uses a high-performance JIT architecture, focused on high throughput JIT compilation. It is much faster than the existing JIT64 64-bit JIT that has been used for the last 10 years.  Before  the 32-bit JIT compiler was a lot faster than the 64-bit version making it sometimes better to compile and run your .NET application in 32-bit.

With the introduction of RyuJIT this gap is finally closed, making it easier to exclusively target 64-bit architectures or migrate workloads from 32- to 64-bit.

What should I do to enable RyuJIT?

The answer is simple; nothing Smile! If you have .NET Framework 4.6 installed, RyuJIT will be enabled for all 64-bit processes running on top of it. Your app will run in a 64-bit process if it is compiled as 64-bit or AnyCPU (although not as Prefer 32-bit), and run on a 64-bit operating system. RyuJIT is similarly integrated into .NET Core, as the 64-bit JIT.

If your servers are 64-bit(they probably are), and your applications are still using 32-bit, it’s time to do some benchmarking and maybe make the switch to 64-bit all the way!

Here is a link to the first time RuyJIT was announced almost 4 years ago: https://blogs.msdn.microsoft.com/dotnet/2013/09/30/ryujit-the-next-generation-jit-compiler-for-net/

Thursday, May 25, 2017

Essential Angular

2 of the core contributors of Angular Victor Savkin and Jeff Cross created a short but complete blog series about all aspects of the Angular framework. If you have never used Angular before or if you want to get a better understanding of how the framework is architected this is a great introduction.

Essential Angular

Here is the full list of posts:

Remark: You can also check out the Essential Angular book, which has some extra content not available in the blog series.

Wednesday, May 24, 2017

Greatness by David Marquet

My boss sent me a link to the following Youtube video:

I especially liked the following quote in the presentation:

“Take control and attract followers. Give control and create leaders”

Tuesday, May 23, 2017

The Microsoft Azure App

While getting up to date with all the great announcements at Build 2017 I noticed a small but interesting fact. It turns out that Microsoft has a mobile app (for iOS and Android) that allows you to manage Azure from your mobile device.

image image

From the documentation:

The Microsoft Azure app helps you keep track of your resources while on-the-go:
- Stay connected to the cloud and check status and critical metrics anytime, anywhere
- Stay informed with notifications and alerts about important health issues
- Stay in control of your resources and take corrective actions, like starting and stopping VMs and web apps

Great! Now can I spin up a new VM while being stuck in traffic Winking smile

Monday, May 22, 2017

TypeScript–Functional magic with discriminated unions and pattern matching

If you like the Functional style of programming, you will be happy to know that TypeScript supports discriminated unions. Instead of using inheritance and creating full blown classes, you can create a simple type that can be of different ‘subtypes’, e.g. a shape can either be a circle, rectangle or square:

This is already a lot less code then when using classes, but another advantage is you can now use pattern matching over this type. The TypeScript uses control flow based type analysis and can identify the different cases in the switch and provides the correct intellisense in each case:

image

Note that I’m using another nice trick to warn me if I missed a switch statement by adding an assertNever function that throws an exception if I forgot to implement one of the cases:

image

Here is the related code:

More information at https://www.typescriptlang.org/docs/handbook/advanced-types.html

Friday, May 19, 2017

VS Code–Angular Language Service

Yesterday while listening to the Adventures in Angular Podcast, I heard someone mention the Angular Language Service extension for VS Code.

From the documentation:

This extension provides a rich editing experience for Angular templates, both inline
and external templates including:

  • Completions lists
  • AOT Diagnostic messages
  • Quick info
  • Go to definition

demo

Thursday, May 18, 2017

Improve performance of your ASP.NET Core application

ASP.NET Core is running on Kestrel, ASP.NET Core’s internal web server. Although really fast Kestrel is not a full blown web server. The idea is that you put another web server(on Windows typically IIS) in front of it that acts as a proxy and forwards the requests to Kestrel.

To get this working in IIS, an AspNetCoreModule exists that achieves this goal. Here is the web.config that configures all of this:

If you look at the configuration, you see that by default all request(path="*" verb="*") are forwarded to Kestrel. This isn't ideal because Kestrel is a lot slower in handling static files than IIS.

A better solution is to only forward the requests that should be handled by ASP.NET Core(by example; path="api/*" verb="*") and let other requests be served by IIS.

The magic trick is to use IIS URL Rewrite rules to forward requests to the wwwroot folder of your ASP.NET Core app:

UPDATE: Rick Strahl did a more complete blog post where he took this approach a few steps further: https://weblog.west-wind.com/posts/2017/Apr/27/IIS-and-ASPNET-Core-Rewrite-Rules-for-AspNetCoreModule

Wednesday, May 17, 2017

Visual Studio Live! Videos

Over the years Visual Studio Live! delivered a lot of great content around the globe. On the Visual Studio Magazine blog, you find an overview of all keynotes. Certainly worth checking out…

One of my favorite sessions - Zero to DevOps with VSTS:

Tuesday, May 16, 2017

Visual Studio 2017–Convert to interpolated string refactoring

C# 6 introduces the concept of string interpolation allowing to use expressions inside your string literals providing a type safe alternative to string.format.

Last week I noticed a related refactoring option in VS 2017; when you have an existing string.format statement Visual Studio allows you to convert it to an interpolated string.

Nice!

clip_image002

Monday, May 15, 2017

No assembly found containing an OwinStartupAttribute

After switching to Visual Studio 2017, one of the projects we were working on started to fail with the following error message:

The following errors occurred while attempting to load the app.

- No assembly found containing an OwinStartupAttribute.

- No assembly found containing a Startup or [AssemblyName].Startup class.

To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config.

To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config.

In our case we don’t need the OWIN startup detection, so we followed the suggestion as mentioned in the error message and updated our config to:

<appSettings>

       <add key="owin:AutomaticAppStartup" value="false" />

</appSettings>

Strange that we didn’t had this problem before VS 2017…

More information:

Friday, May 12, 2017

Take a look into what’s coming next on Azure–The Azure Preview portal

After the “classic” Azure Portal and the “current” Azure Portal, it’s time to introduce a 3th portal, the PREVIEW portal. The Preview Portal allows you to access Azure Portal features before they are released to the main Azure Portal. This enables a sort of “Insider Preview” for just the Azure Portal.

You can access the Azure “Preview” Portal by visiting http://preview.portal.azure.com

image

Thursday, May 11, 2017

ASP.NET core–Log errors to disk

Quick tip if your ASP.NET core application is crashing and you cannot figure out why.

Inside the web.config of the IIS hosting process, change the configuration. Set the sdtoutLogEnabled property to true and specify a location where to output the logs using the stdoutLogFile property.

<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>

Remark: I noticed that I had to create the logs folder first otherwise no files were written to this location…

Wednesday, May 10, 2017

Angular CLI–Documentation and Guidance

I’m a big fan of the Angular CLI, it made my life as an Angular developer a lot easier. It still has some rough edges but Angular was made to use with this kind of tooling.

One of the pieces that is still missing is good documentation. There is some guidance in the Angular documentation and some info on the GitHub website but I found the information to be incomplete(at the moment of writing) and had to fallback to StackOverflow for finding a lot of information.

Last week a colleague heard my complaints about the documentation and sent me a link to The Ultimate Angular CLI Reference Guide. Great tip!

Tuesday, May 9, 2017

.NET Application Architecture

If you want to get some insights on how to architect applications for the .NET stack , Microsoft created https://www.microsoft.com/net/architecture.

Practical advice, best practices, and sample applications for using .NET with microservices, Docker containers, Kubernetes, Xamarin, ASP.NET, Azure, Service Fabric, and more.

image

Monday, May 8, 2017

TFS 2017–How to unconfigure an existing build agent

I couldn’t find good documentation, so here are the steps I used:

  • Browse to the folder where your agent is installed

D:\Builds\Agents\Main1>

  • Execute the /unconfigure command:

D:\Builds\Agents\Main1>agent\vsoagent /unconfigure

Removing EventLog source vsoagent.tfs.Agent-TMD4.

Service vsoagent.tfs.Agent-TMD4 is being removed from the system...

Service vsoagent.tfs.Agent-TMD4 was successfully removed from the system.

Attempt to stop service vsoagent.tfs.Agent-TMD4.

Remark:

First time I tried this, I invoked the command directly from the agent subfolder:

D:\Builds\Agents\Main1\agent>vsoagent /unconfigure

However this failed with the following error message:

You cannot run the vsoAgent.exe interactively from within the Agent folder.

Friday, May 5, 2017

How can I view the used SSL certificate in Chrome?

As of Chrome 56, I noticed that it became a lot harder to inspect the SSL certificate used by a site. You can still access the SSL certificate settings in Windows by opening the Developer Tools (CTRL+SHIFT+i), go to "Security" tab and click the "View Certificate" button.

clip_image002

Thursday, May 4, 2017

TFS Build Agent doesn’t pick up all capabilities

Once a TFS build agent is configured on a build server it should scan the server for all capabilities and add them to a list. These capabilities can then be linked to demands to select an appropriate agent for your specific build script.

image

However at one client we noticed that the list of capabilities for all agents turned out rather empty whereas a lot of components were in fact installed on the server.

Inside the agent logs we found the following error message:

[2017-05-03 09:06:01Z INFO ProcessInvoker] Process started with process id 2828, waiting for process exit.

[2017-05-03 09:06:03Z INFO PowerShellCapabilitiesProvider] STDERR: . : File D:\Builds\dev-agent-3\bin\powershell\Add-Capabilities.ps1 cannot be loaded. The file D:\Builds\dev-agent-3\bin

[2017-05-03 09:06:03Z INFO PowerShellCapabilitiesProvider] STDERR: \powershell\Add-Capabilities.ps1 is not digitally signed. You cannot run this script on the current system. For more in

[2017-05-03 09:06:03Z INFO PowerShellCapabilitiesProvider] STDERR: formation about running scripts and setting execution policy, see about_Execution_Policies at http://go.microsoft.com/f

[2017-05-03 09:06:03Z INFO PowerShellCapabilitiesProvider] STDERR: wlink/?LinkID=135170.

[2017-05-03 09:06:03Z INFO PowerShellCapabilitiesProvider] STDERR: At line:1 char:3

[2017-05-03 09:06:03Z INFO PowerShellCapabilitiesProvider] STDERR: + . 'D:\Builds\dev-agent-3\bin\powershell\Add-Capabilities.ps1'

[2017-05-03 09:06:03Z INFO PowerShellCapabilitiesProvider] STDERR: +   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[2017-05-03 09:06:03Z INFO PowerShellCapabilitiesProvider] STDERR:     + CategoryInfo          : SecurityError: (:) [], PSSecurityException

[2017-05-03 09:06:03Z INFO PowerShellCapabilitiesProvider] STDERR:     + FullyQualifiedErrorId : UnauthorizedAccess

[2017-05-03 09:06:03Z INFO ProcessInvoker] Finished process with exit code 1, and elapsed time 00:00:01.2248303.

On this server a group policy is applied that prevents the execution of unsiged Powershell scripts. As the agent is using Powershell to scan a system for capabilities it failed silenty behind the scenes.

The solution was to ask the server team to sign all scripts for us.

Wednesday, May 3, 2017

Explaining LINQ visually

If you are not convinced in using LINQ yet, go have a look at Michael Sorens blog post. He nicely visualize the behavior of (almost) every LINQ operator and provides a set of characteristics of each LINQ operator explaining position, syntax,execution, laziness, complexity and any optional features.

A must read for every .NET developer!

image

image

Tuesday, May 2, 2017

MSTest–Setting the Culture of your tests

Last week after introducing localization into our application our builds started to fail. Inside the build log we saw that only tests related to localization were failing.

What happened? The problem was that the tests where expecting a specific culture to be set which was different on our local machines compared to the build server. So we needed a way to set the (UI)culture for our tests.

A solution that worked for us was to set the CultureInfo.DefaultThreadCurrentCulture and CultureInfo.DefaultThreadCurrentUICulture in the Assembly initializer of our tests:

 

Remark: Don’t forget to add the [TestClass] attribute on top of your class otherwise MSTest will not invoke the AssemblyInitialize method.

Monday, May 1, 2017

TFS 2017–How to uninstall the ElasticSearch service?

One of the new features of TFS 2017 is the introduction of a code search service. This service is built on top of a customized version of ElasticSearch and can be installed together with the rest of the product.

However the experience is still somewhat rough around the edges.

For example deleting the ElasticSearch service can’t be done through Add/Remove Programs or through an UI but you have to fallback to Powershell instead:

  • Open Powershell as an administrator
  • Go to the folder where ConfigureTFSSearch.ps1 is installed.
  • Run the script again with the remove option: "ConfigureTFSSearch.ps1 -RemoveTFSSearch"

In case you cannot find this Powershell commandlet an alternative option is to browse to the ElasticSearch bin directory and execute the following command:

  • service.bat remove