Friday, October 24, 2014
Thursday, October 23, 2014
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…
Tuesday, October 21, 2014
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…
Monday, October 20, 2014
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…
Friday, October 17, 2014
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 Package Intellisense plugin. This is not required but makes it a little bit easier to use NPM from inside Visual Studio.
Now that we have all prerequisites installed, it’s time to get back to ng-annotate. There exists a ng-annotate plugin for both Grunt and Gulp. Which one you use depends on your own preferences but the process is similar. I will show you how to do it using Grunt. But first we have to install Grunt itself:
- Open a command prompt and install the Grunt command line interface globally by using the following command:
- npm install -g grunt-cli
Open your web project inside Visual Studio. It’s time to add some extra files:
- Add a package.json file to the root of your web project. Also add a gruntfile.js file.
- Inside the package.json, add the following content. In this case I also added a dependency to some other NPM packages to minify and uglify my code:
- Right-click on the package.json file and choose NPM install packages. (If you don’t see this option, open a command prompt and do an npm install from the package.json location).
- After the packages are installed, it’s time to create our gruntfile.js:
We finally arrived at the moment where we can run the Task Runner Explorer:
- Right-click on the gruntfile.js in Visual Studio and choose Task Runner Explorer.
- This will open up the Task Runner Explorer and show all available Grunt tasks.
- Right click on the ngAnnotate task, choose Bindings and click on After build. Now each time we build the ngAnnotate task will automatically rewrite our Angular.js code to add the missing annotations.
Thursday, October 16, 2014
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.
A solution for this is explicitly specifying the dependencies as strings(called explicit function annotation). The ‘ng-strict-di directive’ will check if this syntax is used and throw an exception otherwise.
You can use the $inject Property annotation or use the Inline Array annotation:
Wednesday, October 15, 2014
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 this Preview Edition might be fleshed out, enhanced, or completely reconceived. The final edition of the book will probably be published in the spring of 2015.
You can download PDF and Mobi formats at the Microsoft Virtual Academy.