Skip to main content

Posts

Showing posts from October, 2014

Angular AtScript

I heard some colleagues discuss if Angular.js will ever be written using TypeScript . The answer is no. In fact, the Angular.js team is using their own language AtScript to build Angular 2.0. The goal of AtScript is similar to the goal of TypeScript, it enhances the JavaScript language with some missing features without infringing upon its current capabilities. Here are some of the enhancements and the philosophy behind the language from the Angular.js team design documents : Enhancements Type Annotations: Types allow us to explicitly express contracts between different parts of the system and to give these contracts names. For large teams with large codebases, where no single person knows the whole codebase, types become a key way to discuss and reason about the collaboration between different components of the system. Field Annotations: Types are not only about contracts (API) but also about structure. In JavaScript the fields are implicit;...

ASP.NET Custom Headers–X-UA-Compatible=‘IE=Edge’

If you are building a ‘modern’ web application for Internet Explorer, I would recommend to enable the following header inside your web.config: Using this header will enable ‘Edge mode’ inside IE. It represents the highest support for modern standards available to the browser. In other words, it tells Internet Explorer to use the highest mode available to that version of IE; e.g. Internet Explorer 8 can support up to IE8 modes, IE9 can support IE9 modes and so on. Edge mode was introduced in Internet Explorer 8 and has been available in each subsequent release. Note that the features supported by edge mode are limited to those supported by the specific version of the browser rendering the content. Remark: Starting with IE11, Edge mode is the default mode. Other document modes are deprecated and should no longer be used, except on a temporary basis. Make sure to update sites that rely on legacy features and document modes to reflect modern standards. 

Building cross-platform mobile apps in Visual Studio

Interested in building cross-platform mobile apps using Visual Studio? Microsoft made this easy thanks to the Multi-Device Hybrid Apps Visual Studio extension . This extension allows you to combine Visual Studio and Apache Cordova to easily build hybrid apps that run on iOS, Android, Windows, and Windows Phone using a single project based on HTML and JavaScript. The extension is available for download here . Remark: Be aware that the extension will download and install some additional dependencies, including Joyent Node.js Git CLI Google Chrome Apache Ant Oracle Java JDK 7 Android SDK SQLLite for Windows Runtime Apple iTunes More information can be found at http://www.visualstudio.com/en-us/explore/cordova-vs.aspx .

Internet Explorer–What’s coming next?

Do you want to know what HTML/JavaScript/CSS features will be supported in future versions of Internet Explorer? https://status.modern.ie/ brings you the answer. You see all the features that the IE team is considering to support(and you even can see the support for other browsers).

ASP.NET MVC–CS0234: The type or namespace name ‘’ does not exist in the namespace ‘System.Web.Mvc’

Sometimes you have these issues that always appear randomly. You know you have seen these issues before, but you can’t remember how you fixed them . Today I opened up the project I was working on for the last month to see the following error: CS0234: The type or namespace name ‘’ does not exist in the namespace ‘System.Web.Mvc’ I first tried all the obvious things when you have such an unexpected error: Clean the solution and rebuild the project… Didn’t help Restarting Visual Studio… Didn’t help Delete everything from the Temporary ASP.NET Files folder… Didn’t help Got another coffee at the coffee corner… Didn’t help but I felt a little bit better Finally I noticed that I had switched between configuration modes. Inside the Debug configuration mode, I noticed that Copy Local was set to False for System.Web.MVC . When I changed Copy Local to True everything was working again. Wasted one hour…

TFS Performance Tips

Last week I noticed the following blog post by Cory House; Two Quick TFS Performance Tips . It’s a small post, but one with great value… In his post, he shares one of the greatest performance tips ever about TFS; create a separate workspace for each Team Project . How many times I heard a developer complain that TFS was slow and cumbersome to use… And when I took a look at his Visual Studio solution I had to discover that his 5 years of developer work was all sitting in the same workspace. Ugh…

Announcing Microsoft Connect event

On November 12th,  Microsoft is hosting an online developer event called Connect(); .  Connect(); will be a chance to have a conversation with developers about what’s coming next for developer tools, developer services and application platforms across Microsoft. From the website : “ Connect(); is a cloud-first, mobile-first, code-first virtual event focused on current and future Microsoft technologies for developers. Build on your current skills, unleash your creativity, and expand what's possible to deliver unprecedented innovations.” So if you have any questions about what’s coming next in ASP.NET, this is a great opportunity to get some answers…

Angular.js: Using ngAnnotate inside Visual Studio

Last week I discovered a great NPM module; ‘ ng-annotate ’.It adds and removes AngularJS dependency injection annotations. The great thing is that allows you to use implicit dependencies in Angular.js and ng-annotate will automatically make the switch to the Inline Array annotation. This means that you write  the following code: And that it gets rewritten automatically to: The only problem is that I have to run ngAnnotate from the commandline. As a Visual Studio user, I would like to have an integrated solution. Let’s see how we get this done… Integrate ngAnnotate into Visual Studio To make integration possible, we’ll use some Visual Studio Extensions. So let’s install them first. Start with installing(or upgrading) to the latest version of Web Essentials . Also install node.js on your system. Now it’s time to install Task Runner Explorer . This will allow you to run Grunt and Gulp tasks directly from within Visual Studio. You can also install the ...

Angular.js 1.3: The ng-strict-di directive

Angular.js 1.3 introduces a new directive: ‘ng-strict-di’. <div ng-app="myApp" ng-strict-di> From the documentation : if this attribute is present on the app element, the injector will be created in "strict-di" mode. This means that the application will fail to invoke functions which do not use explicit function annotation (and are thus unsuitable for minification), as described in the Dependency Injection guide , and useful debugging info will assist in tracking down the root of these bugs. To explain this a little bit more; Angular.js does (implicit) dependency injection based on the name of the object you try to inject. So if you specify a parameter as ‘$scope’ it will look for an object called ‘$scope’. This works great until you start using minification. When you minify your JavaScript, the function parameters are shortened to a random letter, e.g. ‘d’. When the injector runs this minifies JavaScript it no longer searches for a ‘$scope’ object...

Another free Xamarin e-book

There is really no excuse anymore to at least read one book about Xamarin. After the free ‘Master Cross-Platform Mobile Development with Xamarin ebook’ I mentioned last week, there is now another free ebook: Creating Mobile Apps with Xamarin.Forms, Preview Edition : Cross-platform C# programming for iOS, Android, and Windows Phone , by Charles Petzold. This ebook was created jointly by Xamarin and Microsoft Press. This Preview Edition ebook is about writing applications for Xamarin.Forms, the new mobile development platform for iOS, Android, and Windows Phone unveiled by Xamarin in May 2014. Xamarin.Forms lets you write shared user-interface code in C# and XAML (the eXtensible Application Markup Language) that maps to native controls on these three platforms. This ebook is a Preview Edition because it's not complete. It has only six chapters. We anticipate that the final version of the book will have at least half a dozen additional chapters and that the chapters in thi...

Fake asynchrony: Avoid the JSON.NET async APIs

As a developer I frequently build my own libraries or re-use existing ones. In the new async/await world, you have to consider if you implement an async version of your library.  However one thing that is important is to avoid “fake asynchrony”. Fake asynchrony is when a component has an async API, but it’s implemented by just wrapping the synchronous API within a task or thread. This will lead to unexpected behavior and can decrease performance. One example of fake asynchrony is Newtonsoft JSON.NET , the known (and great) JSON serialization library. The creators of JSON.NET are already aware of this issue and made the async API’s obsolete:

Angular.js and ASP.NET MVC: IsAjaxRequest returns false when using $http

In an application we are combining Angular.js on the client and ASP.NET MVC on the server. This all works great until we added a call to Request.IsAjaxRequest inside our MVC controller: Inside the controller action we check if we have an AJAX request. If this is the case we return a JSON result otherwise we return an HTML view.  We’ve used similar code(in combination with jQuery) in previous projects without any issues. But when calling the MVC action method through Angular’s $http service, we noticed that the Request.IsAjaxRequest() method returned false . When comparing the requests issued by Angular $http versus jQuery $.get() we noticed one small difference. The xhr call initiated by Angular doesn’t contain the X-Requested-With header. And this is exactly the header ASP.NET MVC is looking for to detect if it’s an AJAX request or not. We can easily fix this by changing the $httpProvider configuration to include this header with every request:

Master Cross-Platform Mobile Development with Xamarin

The guys from Falafel are offering a free e-book about Cross-Platform Mobile development with Xamarin. Go download your copy here (registration required).

Microsoft Azure: Using SSDs in Azure Virtual Machines and Azure Cloud Services

Recently Microsoft released a new set of VM sizes for Microsoft Azure. What makes these new VMs special is that they not only offer faster vCPUs (approximately 60% faster than the A series) and more memory (up to 112 GB), the new VM sizes also all have a local SSD disk (up to 800 GB) to enable much faster IO reads and writes. If you are looking for even better performance, these are the VM sizes you need! The new VM sizes include the following: General Purpose D-Series VMs Name vCores Memory (GB) Local SSD Disk (GB) Standard_D1 1 3.5 50 Standard_D2 2 7 100 Standard_D3 4 14 200 Standard_D4 8 28 400 High Memory D-Series VMs Name vCores Memory (GB) Local SSD Disk(GB) Standard_D11 2 14 1...

ASP.NET Web API error: Can't bind multiple parameters to the request's content

A colleague asked me to help him out with a problem he had with a specific ASP.NET Web API controller. Let’s have a look at his controller first: Inside his web application, he uses a form to post data to this specific controller. However when he runs his application, the post always fails with the following error message: Can't bind multiple parameters to the request's content This is by design. In ASP.NET Web API it isn’t possible to pass multiple parameters by body. As we are using a POST the form data is part of the message body. ASP.NET Web API is unable to extract the form data from the message body and set the parameter values. To get this working, you can either replace the parameters by a FormDataCollection and do the binding yourself or you can create a POCO object to and use the built-in model binders:

NHibernate: Copy an object graph

We are working on an application where we have to create copies of a whole object graph and save this copy as a new object(or better an object tree) to the database. I found 2 possible solutions to get this done: Option 1 – Serialize and deserialize the object tree This is probably the easiest solution. Take the object tree you want to copy, serialize it, deserialize it and attach it to an NHibernate session. The only caveat is that every object in your object tree should be marked as [Serializable]. Option 2 – Combining an ID reset, Session.Evict and some dependency walking Another option is to walk through the object tree yourself while resetting the id values to their default. Don’t forget to remove the objects from the session first by calling Session.Evict.

SQL Server: the database could not be exclusively locked to perform the operation

To get an application up and running, I had to change the Database Collation. But updating it failed with the following error message: The database could not be exclusively locked to perform the operation I was able to fix it by (temporarily) change the database access to SINGLE_USER.

Web API: Binding to form data

Just a quick ASP.NET Web API tip today… If you want to access the form data posted to a an ASP.NET Web API controller, the easiest solution is to use the built-in FormUrlEncodedMediaTypeFormatter, which knows how to map every key/value in the form data to a FormDataCollection . In your controller method, you can specify the FormDataCollection as a parameter:

Adventures in Angular

Already using Angular.js ? Or interested in learning about it? Subscribe to the ‘Adventures in Angular’ podcast; a weekly show dedicated to the AngularJS framework. Certainly check out this weeks episode as Rob Eisenberg talks about what’s coming in Angular 2.0.