.NET Core: Missing mscorlib after installing a Portable Class Library (PCL) or .NET Standard library

October 3, 2016, (updated on October 4, 2016), Software Development

.NET Core projects can reference Portable Class Libraries if one of the .NET Standard compliant profiles is used (e.g. the profile 259). However, after installing a PCL NuGet package in a .NET Core projects, you may end up with the following compiler error: The type '???' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'. To fix this, just install the following PCL compatibility NuGet in your project: Microsoft.NETCore.Portable.Compatibility The package provides bindings for the missing “mscorlib” so that the project can be compiled without problems. Read more...

Tags: , , ,

NSwag Tutorial: Generate an Angular 2 TypeScript client from an existing ASP.NET Web API web assembly

October 1, 2016, (updated on October 7, 2016), 6 comments, Software Development

This tutorial shows how to automatically generate an Angular 2 TypeScript client with the NSwag Swagger toolchain. You can use this client in your Angular 2 SPA (single-page application) to consume the web services of an existing Web API project. The metadata for the client generator will be loaded from an existing .NET assembly which contains your Web API controller classes. The NSwag project provides many other TypeScript templates (for targeting other JS frameworks) and also a C# client generator. For ASP.NET Core projects, I recommend to use the middleware to generate the Swagger spec (there are some problems loading […] Read more...

Tags: , , , , ,

NSwag Tutorial: Integrate the NSwag toolchain into your ASP.NET Web API project

September 30, 2016, (updated on October 1, 2016), Software Development

This tutorial shows how to integrate NSwag (Swagger toolchain for .NET) so that you can access your Web API actions with the Swagger UI and a generated C# client library. The toolchain can be integrated into the following three types of Web API projects: Global.asax-based Web projects (full .NET Framework) OWIN-based Web projects (full .NET Framework) ASP.NET Core based projects (full .NET Framework or .NET Core) For each project, the integration is a little bit different, but this tutorial will provide links to all supported ways. Just follow the steps. 1. Create and setup a new Web API project First […] Read more...

Tags: , , , , , , ,

Script to clone all Git repositories from your VSTS collection

August 23, 2016, Software Development

In this article I show you a PowerShell script which clones and pulls all Git repositories from your Visual Studio Team Services (VSTS) collection. I use this script to retrieve the complete code base so that I can run my code analysis tools on it. 1. Create a new PowerShell script file In the directory where you want to clone all repositories, create a new CloneAllRepos.ps1 script file with the following contents: # Read configuration file Get-Content "CloneAllRepos.config" | foreach-object -begin {$h=@{}} -process { $k = [regex]::split($_,'='); if(($k[0].CompareTo("") -ne 0) -and ($k[0].StartsWith("[") -ne $True)) { $h.Add($k[0], $k[1]) } } $url […] Read more...

Tags: , ,

SystemJS module loader: Enable JavaScript debugging with Visual Studio and Internet Explorer

June 26, 2016, Software Development

In a project, we switched from the JavaScript module loader RequireJS to SystemJS. After the migration, debugging JavaScript directly from Visual Studio in Internet Explorer stopped working. The problem is that Visual Studio cannot detect the loading of script files because SystemJS uses JavaScript HTTP calls instead of injected <script> tags to load modules. But there’s an option in SystemJS to use <script> tags. The option can easily be enabled as follows: <script> System.config({ meta: { "*": { scriptLoad: true } } }); </script> After enabling this setting, JavaScript debugging should work as expected. Read more...

Tags: , , , ,

How to programmatically retrieve the deployment time of an ASP.NET web site

May 26, 2016, Software Development

In one of my web projects, I wanted to append the web site deployment time to the JavaScript URLs. This way the browser uses the cached file version until a new web site version is deployed. To do so, I looked for a way to read the deployment time of the currently running ASP.NET web site. It’s actually very simple, just read the modified date of the applications Web.config: var deploymentTime = File.GetLastWriteTime(Server.MapPath("~/Web.config")) Do you known a better way to do this? Read more...


OpenLayers 3: Add the Bing Maps Traffic layer to your map

April 7, 2016, Software Development

The following code shows how to add the Bing Maps Traffic layer to your OpenLayers 3 map. First, we have to implement the computeQuadKey function which takes the tile coordinates and calculates a quadkey identifier which is required for the Bing API request: var computeQuadKey = function(x, y, z) { var quadKeyDigits = []; for (var i = z; i > 0; i--) { var digit = 0; var mask = 1 << (i - 1); if ((x & mask) != 0) digit++; if ((y & mask) != 0) digit = digit + 2; quadKeyDigits.push(digit); } return quadKeyDigits.join(''); }; With […] Read more...

Tags: , , , ,

JavaScript decorator to add pre- and post-logic to a Promise

March 6, 2016, Software Development

In this blog post, I’ll describe the simple concepts of JavaScript Promise decorators. They are a simple way to add logic which is run before and after the exection of a Promise (a.k.a. aspect-oriented programming). As soon as you see my two samples, you’ll get the idea… The first sample shows a Promise decorator function which shows and hides a loading screen (I use TypeScript typings to show the types of function arguments): function showLoadingScreen<T>(action: () => Promise<T>) { ShowLoadingScreen(); return action().finally(function () { HideLoadingScreen(); }); } The decorator can be used in the following way: function longRunningAction() { return […] Read more...

Tags: , , ,

Asynchronously loaded Unit Tests with Jasmine and RequireJS

March 1, 2016, Software Development

The following check list shows how to write JavaScript Jasmine Unit Tests where the tests are asynchronously loaded from AMD modules with RequireJS. Download the Jasmine source files and extract the lib directory into an empty folder. Download RequireJS and copy the require.js file into the lib directory. In the lib/jasmine/boot.js file, remove the env.execute(); call from the window.onload callback. Create a SpecRunner.html file in the directory root with the HTML content shown below. As you can see, the embedded script loads the defined Unit Test modules and manually calls the previously removed execute() method: <!DOCTYPE html> <html> <head> <meta […] Read more...

Tags: , , , , ,

Angular 2: Convert input values to the correct type with a TypeScript property decorator

February 24, 2016, (updated on March 1, 2016), 7 comments, Software Development

I recently played with Angular 2 and found an uncomfortable problem: Declaring an input property with a TypeScript type does not guarantee that the input value will always be of this type. This is because the Angular framework may update an input with a wrongly typed value and thus is able to “circumvent” the TypeScript type system. As a result, you may end up with strange and unexpected runtime errors. Let’s have a look at this simple Angular component: @Component({ selector: "my-component" }) export class MyComponent { @Input() enabled = true; showValue() { alert(typeof this.enabled); } } As shown in […] Read more...

Tags: , , , ,

  Page 1 of 6 Next Page »