我正在尝试在我的 MVC 3 Web 应用程序中使用 DevExpress 报告“此应用程序是普通的 MVC 3 应用程序,而不是 DevExpress MVC 3 应用程序”,使用以下教程添加 XtraReportshttp://documentation.devexpress.com/#XtraReports/CustomDocument9974 http://documentation.devexpress.com/#XtraReports/CustomDocument9974
问题是每次我尝试添加
@Html.DevExpress().ReportToolbar(settings => {
// The following settings are necessary for a Report Toolbar.
settings.Name = "ReportToolbar";
settings.ReportViewerName = "reportViewer1";
}).GetHtml()
DevExpress() 给我一个错误
“System.Web.Mvc.HtmlHelper”不包含“DevExpress”的定义,并且找不到接受“System.Web.Mvc.HtmlHelper”类型的第一个参数的扩展方法“DevExpress”(您是否缺少 using 指令或装配参考?)
有什么建议么?!
您必须使用此链接中提供的步骤将 Devexpress 组件手动注册到您的项目:
如何:手动注册 DevExpress 扩展以开始在 MVC Web 应用程序中使用它们 http://documentation.devexpress.com/#AspNet/CustomDocument8163
上面提供的步骤中唯一缺少的是程序集绑定重定向。没有它,我会遇到异常:
[InvalidCastException: Unable to cast object of type 'System.Web.Mvc.HtmlHelper`1[System.Object]' to type 'System.Web.Mvc.HtmlHelper'.]
为了防止出现错误,我将此部分添加到我的主 web.config 下<configuration>
:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
这会将较旧的 mvc 程序集版本重定向到 MVC 4。对于 MVC 3,bingingRedirect 行应如下所示:
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)