未能加载类型“System.Web.Mvc.ViewUserControl< SOMETYPE>”

编程入门 行业动态 更新时间:2024-10-26 10:30:50
本文介绍了未能加载类型“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> { }

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

我缺少的东西?

更新

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

  • 使用重建的来源与解决方案的命令行的MSBuild(用于.NET 4)
  • 在启动的自定义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):

  • Rebuild VS solution from source using command-line MSBuild (for .NET 4)
  • 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;”

    本文发布于:2023-11-10 00:35:34,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1573875.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:加载   类型   Web   System   Mvc

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!