未能加载类型“System.Web.Mvc.ViewUserControl< SOMETYPE>” [英] Could not load type 'System.Web.Mvc.ViewUserControl<SOMETYPE>'

查看:365
本文介绍了未能加载类型“System.Web.Mvc.ViewUserControl< SOMETYPE>”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试部署ASP.NET MVC 2项目(VS2010)赢得Server 2008 R2的

它完美地开发计算机上。但奇怪的错误发生在服务器2008 R2: 当.ascx文件有头使用泛型类型:

 <%@控制语言=C#继承=System.Web.Mvc.ViewUserControl< MyProj.Web.Models.RangeViewModel>中%>
 

服务器报道未能加载类型System.Web.Mvc.ViewUserControl< MyProj.Web.Models.RangeViewModel>

但是,当我宣布某处cs文件类型如

 公共类AA:System.Web.Mvc.ViewUserControl< MyProj.Web.Models.RangeViewModel>
{
}
 

和使用它来代替的<%@控的头。然后它的作品,因为它应该。

我缺少的东西?

更新

我部署两个步骤的应用程序(服务器):

  1. 使用重建的来源与解决方案的命令行的MSBuild(用于.NET 4)
  2. 在启动的自定义MSBuild任务(已publih.msbuild文件本)的执行两个目标:目标=ResolveReferences; _CopyWebApplication
解决方案

我看的视图引擎在继承属性编译强类型的基类的问题。我有同样的问题和更新的web.config的页面部分到此帮助:

 <网页
        validateRequest =假
        pageParserFilterType =System.Web.Mvc.ViewTypeParserFilter,System.Web.Mvc,版本= 1.0.0.0,文化=中性公钥= 31BF3856AD364E35
        pageBaseType =System.Web.Mvc.ViewPage,System.Web.Mvc,版本= 1.0.0.0,文化=中性公钥= 31BF3856AD364E35
        userControlBaseType =System.Web.Mvc.ViewUserControl,System.Web.Mvc,版本= 1.0.0.0,文化=中性公钥= 31BF3856AD364E35>
        <控制>
          <添加组件=System.Web.Mvc,版本= 1.0.0.0,文化=中性公钥= 31BF3856AD364E35命名空间=System.Web.Mvc标签preFIX =MVC/>
        < /控制>
        <! - 你的网页部分的休息 - >
< /页>
 

I'm trying to deploy ASP.NET MVC 2 project (VS2010) to Win Server 2008 R2

It works perfectly on dev machine. But strange error occurs at Server 2008 R2: When .ascx file has header that uses generic type:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MyProj.Web.Models.RangeViewModel>" %>

Server reports Could not load type 'System.Web.Mvc.ViewUserControl<MyProj.Web.Models.RangeViewModel>'.

But when I declare somewhere in .cs file type like

public class AA : System.Web.Mvc.ViewUserControl<MyProj.Web.Models.RangeViewModel>
{
}

and use it instead in <%@ Control header. Then it works as it should.

Am I missing something?

UPDATE

I deploy app in two steps (on server):

  1. Rebuild VS solution from source using command-line MSBuild (for .NET 4)
  2. Launch custom msbuild task (have publih.msbuild file for this) that executes two targets: Targets="ResolveReferences;_CopyWebApplication"

解决方案

I looks that the view engine has problems compiling strongly typed base class in Inherit attribute. I had the same issue and updating the "pages" section of Web.Config to this helped:

 <pages
        validateRequest="false"
        pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
        <controls>
          <add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
        </controls>
        <!-- rest of your pages section -->
</pages>

这篇关于未能加载类型“System.Web.Mvc.ViewUserControl&LT; SOMETYPE&GT;”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆