Question

After upgrading to my ASP.NET MVC 4 Developer Preview assemblies to the latest MVC 4 beta, the following exception occurs for my MVC 4 projects:

Could not load type 'System.Web.WebPages.DisplayModes' from assembly
'System.Web.WebPages, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'.

...

Exception Details: System.TypeLoadException: Could not load type
'System.Web.WebPages.DisplayModes' from assembly 'System.Web.WebPages,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

How do I fix this?

Update: I installed the new MVC 4 Beta NuGet package, which added most of the right assemblies, but now I get the missing DisplayModes error on compile:

The name 'DisplayModes' does not exist in the current context.

For the following piece of code in Global.asax.cs:

DisplayModes.Modes.Insert(0, new DefaultDisplayMode("iPhone") { ... });

2nd Update: Solved.

Was it helpful?

Solution

The DisplayModes syntax has changed to:

DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("iPhone")
    {
    ...
    });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top