Friday, May 25, 2012

Could not load type 'System.Web.WebPages.DisplayModes' from assembly 'System.Web.WebPages, Version=2.0.0.0

I got this annoying error recently on my ASP.NET MVC 4 Beta project and didn't find any real solutions/explanations on Google. So after investigating it here are my findings.

The basic problem is that there is a mixup between MVC 4 Developer Preview and MVC 4 Beta .dlls in the project. To see which version you have right click the .dll file in Windows Explorer and choose Properties->Details. Look for  'File Version' :

  • MVC 4 Developer Preview is version 4.0.10906.0
  • MVC 4 Beta is version 4.0.20126.16343


Make sure all says the MVC 4 beta version number (replace the .dlls from a fresh MVC 4 Beta project if necessary) for these files:

  • System.Web.Mvc
  • System.Web.WebPages
  • System.Web.Razor
  • System.Web.WebPages.Deployment
  • System.Web.WebPages.Razor

It should then work.

(Technical: It is actually the older version of System.Web.Mvc.dll that tries to use a removed/changed item in the newer System.Dll.WebPages library. DisplayMode have been replaced with DisplayModeProvider)

Tuesday, May 22, 2012

Fake a mobile device with Chrome

To make Chrome identify as another browser see the comment from Alexander Pavlov here:

http://stackoverflow.com/questions/7561271/user-agent-switcher-for-chrome

I'll repeat it: Open developer tools (Ctrl+Shift+J or Ctrl+Shift+I) and click the small gear icon bottom right to open settings. Check 'Override User Agent' and select the one you want.

This is very useful for testing mobile web pages as you can use chrome to test instead of on a physical device.

Note: This only works as long as you have the developer tools window open, and only in the tab you opened them in.

Column number in Excel

To find the column number (instead of letters) use the Column() command. Eg. for columnt 'AE' write in any cell:

=Column(AE1)

The cell then displays 31 which is the numeric column index (starting at 1). The '1' is after AE specifies the row, doesn't matter wich one you specify so seems quite pointless - but it needs to be there.