未能加载类型“System.Web.Mvc.ViewUserControl&LT; SOMETYPE&GT;” [英] Could not load type 'System.Web.Mvc.ViewUserControl<SOMETYPE>'
问题描述
我尝试部署ASP.NET MVC 2项目(VS2010)赢得Server 2008 R2的
它完美地开发计算机上。但奇怪的错误发生在服务器2008 R2: 当.ascx文件有头使用泛型类型:
&LT;%@控制语言=C#继承=System.Web.Mvc.ViewUserControl&LT; MyProj.Web.Models.RangeViewModel&gt;中%&GT;
服务器报道未能加载类型System.Web.Mvc.ViewUserControl&LT; MyProj.Web.Models.RangeViewModel&GT;
。但是,当我宣布某处cs文件类型如
公共类AA:System.Web.Mvc.ViewUserControl&LT; MyProj.Web.Models.RangeViewModel&GT;
{
}
和使用它来代替的&LT;%@控的头。然后它的作品,因为它应该。
我缺少的东西?
更新
我部署两个步骤的应用程序(服务器):
- 使用重建的来源与解决方案的命令行的MSBuild(用于.NET 4)
- 在启动的自定义MSBuild任务(已publih.msbuild文件本)的执行两个目标:目标=ResolveReferences; _CopyWebApplication
我看的视图引擎在继承属性编译强类型的基类的问题。我有同样的问题和更新的web.config的页面部分到此帮助:
&LT;网页
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&GT;
&LT;控制&GT;
&LT;添加组件=System.Web.Mvc,版本= 1.0.0.0,文化=中性公钥= 31BF3856AD364E35命名空间=System.Web.Mvc标签preFIX =MVC/&GT;
&LT; /控制&GT;
&LT;! - 你的网页部分的休息 - &GT;
&LT; /页&GT;
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;”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!