问题
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
.
An exception of type 'System.ArgumentNullException' occurred in mscorlib.dll
Value cannot be null. Parameter name: key
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.
Adding @Html.Stimulsoft().RenderMvcViewerScripts()
wasn't useful neither.
This is the view:
@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>
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>
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>
It's been suggested to add the following bindingRedirect
to 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>
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.
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.
回答1:
Add this line in appsettings in web.config
<add key="PageInspector:ServerCodeMappingSupport" value="Disabled" />
Maybe your report file created with different version of Stimulsoft.
来源:https://stackoverflow.com/questions/31633320/system-argumentnullexception-while-using-stimulsoft