This is a migrated thread and some comments may be shown as answers.

[Solved] Could not load type system.web.mvc.ModelMetaData error

2 Answers 42 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
James Fleming
Top achievements
Rank 1
James Fleming asked on 12 May 2010, 03:58 PM
Here is my situation:
 I've introduced the (awesome) grid control and got it working fine on my dev environment.

I deployed my site to my local dev server and got the following error:
Could not load type 'System.Web.Mvc.ModelMetadata' from assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutralPublicKeyToken=31bf3856ad364e35'.   
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.   
 
Exception Details: System.TypeLoadException: Could not load type 'System.Web.Mvc.ModelMetadata' from assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutralPublicKeyToken=31bf3856ad364e35'.  
 
Source Error:   
 
 
Line 10:     .Columns(columns => 
Line 11:     {  
Line 12:         columns.Bound(x => x.Id);  
Line 13:         columns.Bound(x => x.RequestTypeCode);  
Line 14:         columns.Bound(x => x.ReceiptNumber).Title("Receipt #").Width(85);  
   
 
Source File: d:\Inetpub\wwwroot\LTRS\Web\Views\Search\_SearchList.ascx    Line: 12   
 
Stack Trace:   
 
 
[TypeLoadException: Could not load type 'System.Web.Mvc.ModelMetadata' from assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutralPublicKeyToken=31bf3856ad364e35'.]  
   Telerik.Web.Mvc.UI.GridBoundColumn`2..ctor(Grid`1 grid, Expression`1 expression) +0  
   Telerik.Web.Mvc.UI.Fluent.GridColumnFactory`1.Bound(Expression`1 expression) +80  
   ASP.views_search__searchlist_ascx.<__Render__control1>b__7(GridColumnFactory`1 columns) in d:\Inetpub\wwwroot\LTRS\Web\Views\Search\_SearchList.ascx:12  
   Telerik.Web.Mvc.UI.Fluent.GridBuilder`1.Columns(Action`1 configurator) +107  
   ASP.views_search__searchlist_ascx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in d:\Inetpub\wwwroot\LTRS\Web\Views\Search\_SearchList.ascx:8  
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256  
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19  
   System.Web.UI.Control.Render(HtmlTextWriter writer) +10  
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27  
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99  
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25  
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134  
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19  
   System.Web.UI.Page.Render(HtmlTextWriter writer) +29  
   System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +59  
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27  
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99  
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25  
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266  
 
   
 
3.5 framework SP1
The version of the site which is having the error is using MVC R2 (System.Web.Mvc is version 2.0.40724.0)

The View code is below:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<Ltrs.Data.Transaction>>" %> 
<%@ Import Namespace="MvcContrib.UI.Grid" %> 
    
    <%  
        int pageSize = 10;  
        SelectList select = ViewData["Take"] as SelectList;  
        int.TryParse(select.SelectedValue.ToString(), out pageSize);  
     Html.Telerik().Grid(Model)  
    .Name("Grid")  
    .Columns(columns => 
    {  
        columns.Bound(x => x.Id);  
        columns.Bound(x => x.RequestTypeCode);  
        columns.Bound(x => x.ReceiptNumber).Title("Receipt #").Width(85);  
        columns.Bound(x => x.CheckNumber).Title("Check #").Width(85);  
        columns.Bound(x => x.RequesterName).Title("Requestor").Width(120);  
        columns.Bound(x => x.StatusTypeCode).Title("Status");  
        columns.Bound(x => x.RequestDate).Format("{0:MM/dd/yyyy}").Title("Requested");  
    })  
    .DataBinding(dataBinding => dataBinding.Ajax().Select("_Paging", "Search"))  
            .Pageable(  
                paging => paging.PageSize(pageSize)  
                    .Style(GridPagerStyles.NextPreviousAndNumeric)  
                    .Position(GridPagerPosition.Bottom)  
                    )  
             .Sortable(sorting => sorting.Enabled(true))  
             .Scrollable(scrolling => scrolling.Enabled(true))  
             .Selectable().ClientEvents(events => events.OnRowSelected("onRowSelected")).RowAction(row => { row.Selected = row.DataItem.Id.Equals(ViewData["id"]); })  
              .Filterable(filtering => filtering.Enabled(true))                
    .Render(); 

I was able to resolve this error by uninstalling MVC R2 and replacing it with MVC R2v2 (this environment also required an update of VS2008 sp and update of 3.5 framework Sp as well b/c VS is installed on this box), and then everything worked fine.
My problem is, the PHB won't allow me to update the version of MVC on our System Testing environment from MVC R2.

The requirements for the Telerik MVC controls don't specify MVC R2v2 as required, but the only blog posting that was close to addressing the problem suggested this and it seemed to work.

My local version and the dev site version of System.Web.Mvc is v2.0.50727

Help me Obi Wan! You're my only hope!

2 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 13 May 2010, 08:19 AM
Hello James Fleming,

I am not sure what you mean by MVC 2R2 or 2R. Telerik Extensions for ASP.NET MVC support only ASP.NET MVC 1 and ASP.NET MVC 2 RTM which is the latest official version. The assembly file version of System.Web.Mvc.dll should be 2.0.50217.0. Other versions are not supported.

All the best,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
James Fleming
Top achievements
Rank 1
answered on 13 May 2010, 12:18 PM
For clarification: when I  had the System.Web.Mvc 2.0.40724.0 ( a version between version 1 and version 2 RTM) being read from the GAC, i was getting the above ModelMetaData error. Complicating things was my PHB not allowing me to update the GAC. Also, ASP.NET MVC wasn't visible to gacutil, so we weren't able to force a reinstall of the RTM version of the dll.

We finally convinced the PHB to allow us to do so. The solution in our case which satisfied both the error and the PHB was to uninstall ASP.NET MVC via Add/remove programs, and give each of our MVC applications their respective version of the dll in their bin file. (For those not aware the GAC version trumps the Bin version.)

We're good to go now.

Thanks Telerik for the awesome tool - and thanks for supporting .NET Rocks!
Tags
Grid
Asked by
James Fleming
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
James Fleming
Top achievements
Rank 1
Share this question
or