Thursday, September 08, 2011

Use WinMerge in Visual Studio 2010 and TFS

Shamelessly stolen from Sebastien Lambla:

Go to Tools, Options, Source Control, Visual Studio Team Foundation Server, Configure User Tools...

Add a Compare pointing to WinMergeU.exe and using:

    /e /x /s /wl /dl %6 /dr %7 %1 %2

as a command-line argument.

Repeat the operation for Merge, this time using:

    /e /s /x /ub /dl %6 /dr %7 %1 %2 %4

WinMerge is usually found in:

    C:\Program Files (x86)\WinMerge\WinMergeU.exe

Friday, December 03, 2010

ASP.NET MVC: The model of type ‘xxx’ could not be updated

The actual exception thrown is System.InvalidOperationException.

Set a breakpoint where the exception occurs. If you are calling UpdateModel, chances are you will find one or more validation exceptions in the ModelState.

Wouldn’t it be nice if the error message just said so?

Friday, October 15, 2010

How to stop automatic newline in ASP.NET code blocks

I want to keep my one liner code blocks in my ASP.NET MVC views as:

  1. <% Html.BeginForm(); %> 

Unfortunately, a not so helpful feature recognize the C# code and reformats to the following:

  1. <%  
  2.    Html.BeginForm(); %> 

Thanks to Erv Walter for solving the problem.

In short, to remove this feature we have to:

  • Go to Tools – Options – Text Editor – HTML – Formatting
  • Select Tag Specific Options…
  • Under Client HTML Tags, add three tags: “%”, “%:”, and “%=”

The %-tag should have line breaks before and after, and no closing tag.

The %: and %= tags should have no closing tag, and no line breaks.

For ReSharper-users, also remember to disable Auto-formatting on semicolon, and on closing brace. Otherwise, ReSharper will interfere and reformat.

Tuesday, September 21, 2010

Blank page in ASP.NET MVC, IIS and Windows 7

You decide to move your web application from the internal web server to IIS under Windows 7, but observe nothing but a blank page.

Seems like it’s not enough to just add IIS from within Programs And Features – Turn Windows features on or off, but some additional tricks are required.

When activating World Wide Web Services within Turn Windows features on or off, remember to include:

  • HTTP Errors
  • HTTP Redirection

Even if ASP.NET is already selected, the following command line must be executed. Remember to run cmd as Administrator:

  1. %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe –ir   


Friday, September 17, 2010

Can’t connect MyMobiler due to a busy ActiveSync connection

I installed MyMobiler on my computer, but couldn’t connect to my HTC HD2. The exact words in the message has slipped my mind, but it said something about an ActiveSync connection being busy.

In my case, that message was both unhelpful and totally wrong. The real reason was missing drivers on my Windows 7 64-bit system:

  1. Download and install the drivers.
  2. Reconnect the phone, make sure to select the ActiveSync option.
  3. Wait for the driver to complete the install.
  4. Exit MyMobiler and start it again.


Thursday, September 16, 2010

Online code syntax highlighter

I never get around to find out how to modify my blog template to include javascript for syntax highlighting.

So I use this online service:

Use Mercurial to remove TFS friction

TFS, unfortunately, does some things wrong by default. If the client is anything except Visual Studio, the user experience is abysmal when it comes to commit file changes.

These days I created wireframes in Mockups for all my screens. But checking in those files were so difficult that I routinely procrastinated the task. I have installed TFS Power Tools with its shell extension, but that UI suffers from the same usability issues.

One possible workaround is to use TortoiseHg, which is pretty frictionless. Eric Hexter at LosTechies has an excellent recipe on how to set up Mercurial as a local repository for TFS. He didn’t, however, provide the source code for the Power Shell scripts. I typed them up here with minor adjustments.


  1. $projectName = "your-project"  
  2. $tf = "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe"  
  4. function pull{  
  5.     cd "\your\tfs\folder"  
  6.     &$tf get  
  7.     hg commit -A -m "from tfs"  
  8.     cd "your\working\hg\folder"  
  9.     hg pull --rebase  
  10. }  
  12. pull 


  1. $projectName = "your-project"  
  2. $tfpt = "C:\Program Files (x86)\Microsoft Team Foundation Server 2010 Power Tools\tfpt.exe"  
  3. $tf = "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe"  
  4. hg push  
  5. cd "\your\tfs\folder"  
  6. &$tfpt scorch /noprompt /exclude:.hgignore`,*.ps1`,.hg  
  7. hg update -C -y  
  8. &$tfpt online /adds /exclude:.hgignore`,*.ps1`,.hg`,_ReSharper`,bin`,obj`,*.user`,*.suo  
  9. &$tf checkin  
  10. cd "your\working\hg\folder"