asp.net-mvc-3 - Devexpress 在 razor mvc3 中添加报告时出错

标签 asp.net-mvc-3 devexpress

我正在尝试在我的 MVC 3 Web 应用程序中使用 DevExpress 报告“此应用程序是普通的 MVC 3 应用程序,而不是 DevExpress MVC 3 应用程序”,使用以下教程添加 XtraReports 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' 的定义并且没有扩展方法 'DevExpress' 接受类型为 'System.Web.Mvc.HtmlHelper' 的第一个参数可以找到(你错过了吗using 指令还是程序集引用?)

有什么建议吗?!

最佳答案

您必须使用此链接中提供的步骤手动将 Devexpress 组件注册到您的项目:

How to: Manually Register DevExpress Extensions to Start Using Them in an MVC Web Application

上面提供的步骤中唯一缺少的是程序集绑定(bind)重定向。没有它,我得到了异常(exception):

[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,bindingRedirect 行应该是这样的:

<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />

关于asp.net-mvc-3 - Devexpress 在 razor mvc3 中添加报告时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12288625/

相关文章:

asp.net-mvc - 当它由@Html 助手生成时,如何在 MVC 中更改 'data-val-number' 消息验证

c# - Asp.net LINQ groupby 和 orderBy 日期不检索预期的输出

c# - 如何在不离开根组件的情况下处理大量 "dialogs"?

wpf - 未使用 wpf 在 DevExpress GridControl 中选中复选框

.net - 更改、覆盖、替换、asp.net MVC 3 默认 DataAnnotations 所需值和无效值的验证消息

c# - jQuery 可排序 : How to properly post element id array?

winforms - 从数据绑定(bind)的 DevExpress CheckedListBoxControl 获取项目索引

wpf - 如何使用 wpf GridControl DevExpress 单击单元格时动态获取列索引?

c# - 如何在 C# 中动态分配运行时的表格单元格宽度?

asp.net-mvc-3 - MVC3 非顺序索引和 DefaultModelBinder