使用Stimulsoft时出现"System.ArgumentNullException" [英] 'System.ArgumentNullException' while using Stimulsoft

查看:248
本文介绍了使用Stimulsoft时出现"System.ArgumentNullException"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的MVC 5.2应用程序中使用Stimulsoft Reports 2014.3.尝试使用@Html.Stimulsoft().StiMvcViewer时,出现以下异常.

I'm trying to use Stimulsoft Reports 2014.3 in my MVC 5.2 app. I get the following exception when I try to use @Html.Stimulsoft().StiMvcViewer.

mscorlib.dll中发生了'System.ArgumentNullException'类型的异常

An exception of type 'System.ArgumentNullException' occurred in mscorlib.dll

值不能为null.参数名称:键

Value cannot be null. Parameter name: key

我可以使用@Html.Stimulsoft().StiMvcViewerFx就好了.我尝试了web.config中的各种更改来解决此异常,但是它们都没有用.我也尝试过Debug->异常,并选中两个框的公共语言运行时异常",但没有其他异常.

I can use @Html.Stimulsoft().StiMvcViewerFx just fine. I have tried various changes in web.config to get ride of this exception, but they were all useless. I've also tried Debug -> Exceptions, and checking both boxes for Common Language Runtime Exceptions, but there wasn't any other exception.

添加@Html.Stimulsoft().RenderMvcViewerScripts()也是没有用的.

这是视图:

@using Stimulsoft.Report.Mvc
@using System.Web.UI.WebControls
@model Models.GenericReportViewModel

<div>
    @Html.Stimulsoft().StiMvcViewer(new StiMvcViewerOptions()
{
    ActionGetReportSnapshot = string.Concat("LoadReport?Id=", Model.ReportName),
    Width = Unit.Point(500),
    Theme = StiTheme.Default,
    ActionExportReport = "ExportReport",
    Height = Unit.Point(400),
    Controller = "Report",
})
</div>

这是web.config:

This is the web.config:

  <system.web>
      <globalization uiCulture="fa-IR" culture="fa-IR"></globalization>
    <compilation debug="true" targetFramework="4.5">
      <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="Stimulsoft.Base, Version=2014.3.0.0, Culture=neutral, PublicKeyToken=ebe6666cba19647a" />
        <add assembly="Stimulsoft.Report, Version=2014.3.0.0, Culture=neutral, PublicKeyToken=ebe6666cba19647a" />
        <add assembly="Stimulsoft.Report.Mvc, Version=2014.3.0.0, Culture=neutral, PublicKeyToken=ebe6666cba19647a" />
      </assemblies>
    </compilation>
    <httpRuntime targetFramework="4.5" />
    <pages>
      <namespaces>
        <add namespace="Kendo.Mvc.UI" />
        <add namespace="System.Web.Helpers" />
        <!--<add namespace="System.Web.Abstractions" />-->
        <add namespace="Stimulsoft.Base" />
        <add namespace="Stimulsoft.Report" />
        <add namespace="Stimulsoft.Report.Mvc" />
      </namespaces>
    </pages>
  </system.web>

我应该注意,Flash版本的工作方式如下,并且没有任何问题:

I should note that the Flash version works as below and it doesn't have any problem:

@using Stimulsoft.Report.Mvc
@using System.Web.UI.WebControls
@model Models.GenericReportViewModel

<div>
    @Html.Stimulsoft().RenderMvcViewerFxScripts()
    @Html.Stimulsoft().StiMvcViewerFx(new StiMvcViewerFxOptions()
{
    ActionGetReportSnapshot = string.Concat("LoadReport?Id=", Model.ReportName),
    Width = Unit.Point(500),
    Theme = StiMvcViewerFxOptions.Themes.Blue,
    ActionExportReport = "ExportReport",
    BackgroundColor = System.Drawing.Color.Silver,
    ActionGetLocalization = "GetLocal",
    Height = Unit.Point(400),
    Controller = "Report",
})
</div>

建议将以下bindingRedirect添加到web.config

  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.1" />
  </dependentAssembly>

添加此选项将抑制异常并阻止呈现页面,这可能是因为我没有使用MVC 3!但是它应该与此有关.

Adding this will suppress the exception and prevents the page from rendering, probably because I'm not using MVC 3! But it should have something to do with it.

我也将其重定向为oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0",但是我将获得异常.

I also have this redirect as oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0", but I'll get the exception with this one.

推荐答案

在web.config的appsettings中添加此行

Add this line in appsettings in web.config

<add key="PageInspector:ServerCodeMappingSupport" value="Disabled" />

也许您的报告文件是使用不同版本的Stimulsoft创建的.

Maybe your report file created with different version of Stimulsoft.

这篇关于使用Stimulsoft时出现"System.ArgumentNullException"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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