Friday, January 31, 2014

Upgrading to Entity Framework 6

Be careful when you upgrade to Entity Framework 6, because it introduces some breaking changes.

Entity Framework 6 is the first version that is not tied to the .NET framework directly. This allows Entity Framework to evolve independently from the .NET framework. Unfortunaltey this couldn’t be done without introducing some breaking changes.

From the MSDN site:

Types like ObjectContext that were previously in System.Data.Entity.dll have been moved to new namespaces. This means you may need to update your using or Import directives to build against EF6.

The general rule for namespace changes is that any type in System.Data.* is moved to System.Data.Entity.Core.*. In other words, just insert Entity.Core. after System.Data. For example:

  • System.Data.EntityException => System.Data.Entity.Core.EntityException
  • System.Data.Objects.ObjectContext => System.Data.Entity.Core.Objects.ObjectContext
  • System.Data.Objects.DataClasses.RelationshipManager => System.Data.Entity.Core.Objects.DataClasses.RelationshipManager

These types are in the Core namespaces because they are not used directly for most DbContext-based applications. Some types that were part of System.Data.Entity.dll are still used commonly and directly for DbContext-based applications and so have not been moved into the Core namespaces. These are:

  • System.Data.EntityState => System.Data.Entity.EntityState
  • System.Data.Objects.DataClasses.EdmFunctionAttribute =>System.Data.Entity.DbFunctionAttribute
    Note: This class has been renamed; a class with the old name still exists and works, but it now marked as obsolete.
  • System.Data.Objects.EntityFunctions => System.Data.Entity.DbFunctions
    Note: This class has been renamed; a class with the old name still exists and works, but it now marked as obsolete.)
  • Spatial classes (e.g. DbGeography, DbGeometry) have moved from System.Data.Spatial => System.Data.Entity.Spatial

Thursday, January 30, 2014

TypeScript and the ‘this’ keyword

One thing I was not aware of is that TypeScript will not automatically scope the this keyword to what you would expect. Only if you use the TypeScript arrow functions it will correctly set ‘this’ inside a function.

So the following code inside my TypeScript was wrong. In this code sample ‘this’ will refer to the caller object and not to the FormChangeTracker class as I would expect:

When I use the arrow function instead, this will be scoped correctly:

Wednesday, January 29, 2014

TypeScript: Allow any number of arguments

In JavaScript, functions don’t have a fixed signature and can be called with any number of arguments. Arguments that are not part of the function signature can be accessed through the arguments array(which actually isn’t a real array, but that’s another discussion).
But what if you want to build a similar functionality inside TypeScript? It took me some time to figure out how to get this working.
This functionality is supported through the ‘…’ rest parameter, an EcmaScript 6 proposal. This parameter collects any extra arguments passed to the function into a single named array:
Calling doSomething('a', 'b', 'c', 'd') would set argument a to a string 'a', argument b to a string ‘b’ and theArgs to be an array [ 'c', 'd' ].

Tuesday, January 28, 2014

Error after upgrading to ASP.NET MVC 5

After updating my NuGet packages to MVC 5, my website started to fail with the following error message:
“Attempt by security transparent method ‘System.Web.Mvc.PreApplicationStartCode.Start()’ to access security critical method ‘System.Web.WebPages.Razor.PreApplicationStartCode.Start()’ failed.”








If you see this error, it probably means that not everything is upgraded correctly inside your web project. Go have a look at http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2 and carefully check if you applied all steps.

Monday, January 27, 2014

IIS URL rewrite rules

One of the things that always annoys when a visit a website is that sometimes they support  www.websiteurl.com but not websiteurl.com. So if you try to remember the URL(to train your memory muscles) , there is 50% chance that you type the wrong address.

www

Fixing this is easy if your site is hosted in IIS, by using the URL rewrite module you can map between www.websiteurl.com and websiteurl.com anyway you want. I’m not good in writing these URL rewrite rules but luckily for me (and you), Mads Kristensen did the job for us. In this blog post he explains the exact rules needed to configure this for your IIS sites.

Thanks Mads!

Friday, January 24, 2014

Git tags: push to a remote Git repository based on a tag

I noticed when I pushed changes to a remote Git repository, it doesn’t send the tags I’ve created along with the other changes. Is there anyone who knows if this is normal behavior?

In the meanwhile I solved the issue by pushing the tags explicitly using the following command:

  • Push all tags:
    • git push –tags
  • Push a single tag:
    • git push origin <tag_name>

Thursday, January 23, 2014

Visual Studio 2013 Git support: Missing features

The last weeks I’m starting to use the Git integration in Visual Studio 2013. Before I always used the command line or GitHub for Windows, but now it’s time for a new adventure…
One of the things I missed inside Visual Studio was the support of Git tags. Git tags offer a similar experience as labels in Team Foundation Server Version Control.  A tag is essentially a pointer to a specific commit. You can use tags to label a certain point in time in your codebase. Many teams use tags to point to a release point.
If you want to apply tags, you still have to switch to the command prompt:
$ git tag -a v1.4 -m 'my version 1.4'
Remarks: At the following link, you can find a comparison between features available inside Visual Studio and the Command prompt; http://msdn.microsoft.com/en-us/library/dd286572.aspx

Wednesday, January 22, 2014

Comparing NO-SQL solutions

There are a lot of NO-SQL solutions out there. So choosing one, can be a daunting task.

Kristof Kovacs made a comparison between of Cassandra, Mongodb, CouchDB, Redis, Riak, Couchbase (ex-Membase), Hypertable, ElasticSearch, Accumulo, VoltDB, Kyoto Tycoon, Scalaris, Neo4j and HBase.

So if you are interested in NO-SQL solutions, but need some help in finding one that fits your purposes, go read his blog post: http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis

Tuesday, January 21, 2014

TFS Build: Build from a Git tag

The TFS Build system not only works fine with Team Foundation Version Control but also with Git.

I was looking for a way to specify the git tag(similar to a label in the TFS Version Control) inside a build definition.

However when I created a new build definition, I couldn’t find a relevant option in the build process parameters:

image

The trick is that you don’t need to use the Default Template(GitTemplate.xaml) but switch to a newer version:

image

After doing that I can specify a tag id in the Checkout override field:

image

Remark: By default you have to type the tag id yourself(with a change of typo’s). To select the tag id from a list of possible values, have a look at the following post on StackOverflow that explains how to configure a custom editor: http://stackoverflow.com/questions/19434527/how-to-setup-tfs-2013-build-definition-to-build-from-git-tag

Monday, January 20, 2014

Configure Git(Hub for Windows) to work through proxies

If you’re behind a corporate firewall, chances are that you have some trouble using GitHub for Windows against a remote repository. This is because most organizations use some kind of proxy.
Most of the time you get an error like:
fatal: unable to access 'https://github.com/wullemsb/asampleapp/': Received HTTP code 407 from proxy after
 CONNECT


We have to tell GitHub for Windows to use this proxy as well. Therefore you have to edit the .gitconfig file typically found at C:\Users\<yourusername>\.gitconfig or C:\Documents & Settings\<yourusername>\.gitconfig.


In the .gitconfig file , add the following lines
   
[http]
proxy = http://myproxyserver.acme.com:8080


[https]
proxy = http://myproxyserver.acme.com:8080


As an alternative you can also use the command line:

git config --global http.proxy http://myproxyserver.acme.com:8080

Friday, January 17, 2014

Installing Ruby Gems when sitting behind the firewall

For a customer project, I had to use some Ruby tools. To include some external libraries I opened up gem, the package manager of Ruby.

So I opened a command prompt and triggered the installation of the package I needed:

gem install ‘svn2git’

But no matter what I tried, it always failed with the following error message:

ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    too many connection resets (
http://rubygems.org/latest_specs.4.8.gz)

I figured out that it was caused by the proxy script that was used on the customer’s pc I was using. As the environment was well secured, I couldn’t do anything to bypass the proxy.

Luckily there is a workaround(isn’t there always one? Knipogende emoticon)

image

  • Search for the gem that you are interested in.
  • On the gem page, you’ll find  a download button. Click it to download the gem directly and save it to the directory of your choice.

image

  • To install the downloaded gem, browse to the location where you saved it and execute the following command:

gem install svn2git-2.2.2.gem

  • That’s it!

Thursday, January 16, 2014

.NET error: The client or server is only configured for E-mail addresses with ASCII local-parts: hergé@tintin.be

For a customer project, I created a batch application that every night send hundreds of emails(my own kind of SPAM machine Knipogende emoticon).

Last week, we started getting some errors. When we looked inside the error logs, we found the following error message:

The client or server is only configured for E-mail addresses with ASCII local-parts: hergé@tintin.be

To solve this we have to upgrade our application to .NET 4.5. In .Net 4.5 an extra property was added to the SmtpClient, DeliveryFormat which accepts values of the System.Net.Mail.SmtpDeliveryFormat type. If you change this value to SmtpDeliveryFormat.International, the SmtpClient will happily send any kind of emailadres, no matter what strange characters it contains.

Wednesday, January 15, 2014

Visual Studio error: The runtime has refused to evaluate the expression at this time

To debug an issue inside one of my applications, I added a conditional breakpoint and used the following expression ‘container.Registrations.Count() <10’.

No luck however… When I tried to run the application Visual Studio started to complain and showed the following error message:

clip_image002

No idea why this doesn’t work Bedroefde emoticon

Anyone who knows how to fix this or has an explanation why it doesn’t work?

Tuesday, January 14, 2014

TypeScript: TypeScript files inside a class library are not compiled

When you add TypeScript files to a class library and build the project, you’ll see that nothing happens. No matter what you try, no JavaScript files are created.
After comparing the csproj file with a MVC Web project, I noticed that a targets file is not referenced. I guess it’s a bug in the Visual Studio tooling…
To fix this, execute the following steps:
  • Unload the project
  • Edit the project file using an XML editor
  • Add the following line
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" />

after

  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • Save the file and reload the project
If you now try to build, the JavaScript files will be generated as expected.

Monday, January 13, 2014

TypeScript: Add properties to an object’s prototype

When you try to add a property to an object’s prototype using TypeScript, you’ll get a compiler error inside Visual Studio.

image

image

Too get rid of the error message, you’ll have to create an interface on the prototype object type and declare the function there:

Friday, January 10, 2014

Metro UI CSS 2.0

If you like the “Modern”(a.k.a Metro) UI in Windows 8(.1), and want to use a similar user experience in your websites, have a look at Metro UI CSS 2.0. It offers a set of styles and components to create a site with an interface similar to Windows 8.

image

Thursday, January 9, 2014

Microsoft Application Insights: The specified collection plan, version 1.0, is not supported.

After the announcement of the new Application Insights feature in Visual Studio Online, I subscribed to the beta program. After registration, I downloaded the Microsoft Monitoring Agent. So far, everything was fine. However the moment I tried to start the Monitoring Agent the fun was over. No matter what I tried I always got the following error message:

“The specified collection plan, version 1.0, is not supported. This installation of Microsoft Monitoring Agent support collection plan version from 1.0 to 1.0”

clip_image002

When looking through the comments on the announcement post, someone mentioned the same error message. It seems that the Monitoring Agent only works on an English OS Bedroefde emoticon. I hope they’ll fix this soon…

Wednesday, January 8, 2014

Chrome Developer Tools: console.table()

I discovered a nice feature in the Chrome Developer Tools.

Let’s imagine that you got an array of products from an AJAX web service call:

var products = [
    { name: "XBOX", price: "200 $" },
    { name: "Playstation", price: "180 $" },
    { name: "Nintendo", price: "100 $" }
];

If you log this array to the console using console.log() , you don’t get anything useful back:

image

A nicer alternative is the usage of console.table(), which gives you the following result:

image

Tuesday, January 7, 2014

Another Christmas gift: Getting Value out of Agile Retrospectives - A Toolbox of Retrospective Exercises

InfoQ offers a free ebook “Getting Value out of Agile Retrospectives - A Toolbox of Retrospective Exercises”.

This pocket book contains many exercises that you can use to do retrospectives, supported with the “what” and “why” of retrospectives, the business value and benefits that they can bring you, and advice for introducing and improving retrospectives.
Agile retrospectives are a great way to continuously improve your way of working. Getting actions out of a retrospective that are doable, and getting them done helps teams to learn and improve. We hope that this book helps you and your teams to do retrospectives effectively and efficiently to reflect upon your ways of working, and continuously improve them!

Go download it PDF, ePub or MOBI format.

Monday, January 6, 2014

Customizing Team Foundation Server

Although there is a lot of information out there about customizing Team Foundation Server, it’s not always easy to find. KathrynE gaves us a nice Christmas present by grouping all this information together in one blog post.

It gives you links to topics that show how to configure or customize areas related to version control, build, work tracking, and testing using TFS.

Go check it out!

ChristmasPresents