asp.net-mvc 本地报告处理过程中发生错误。报告的定义 ' 无效

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22601364/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 03:36:35  来源:igfitidea点击:

An error occurred during local report processing.The definition of the report ' is invalid

asp.net-mvcvisual-studio-2012reporting-serviceswindows-server-2008

提问by Prasanna

I am new to using SSRS. I am using a .rdlcfile for report generation in a PDF with VS 2012. When I tried to set the parameters like

我是使用 SSRS 的新手。我正在使用.rdlcVS 2012 在 PDF 中生成报告的文件。当我尝试设置参数时

ReportParameter param = new ReportParameter(kvp.Key, kvp.Value);
LocalReport.SetParameters(param);

This throws an exception:

这会引发异常:

An error occurred during local report processing..The definition of the report '' is invalid.. Could not load file or assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Access is denied.

本地报告处理过程中发生错误。报告“的定义无效”。无法加载文件或程序集“System.Web,版本=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”或其依赖项之一. 访问被拒绝。

More details:

更多细节:

{Microsoft.Reporting.WebForms.LocalProcessingException: An error occurred during local report processing. ---> Microsoft.Reporting.DefinitionInvalidException: The definition of the report '' is invalid. ---> System.IO.FileLoadException: Could not load file or assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Access is denied.
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Activator.CreateInstance(String assemblyString, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(String assemblyName, String typeName)
   at System.AppDomain.CreateInstance(String assemblyName, String typeName)
   at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName)
   at System.AppDomain.CreateAppDomainManager()
   at System.AppDomain.Setup(Object arg)
   at System.AppDomain.nCreateDomain(String friendlyName, AppDomainSetup setup, Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, IntPtr parentSecurityDescriptor)
   at System.AppDomainManager.CreateDomainHelper(String friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo)
   at System.AppDomainManager.CreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo)
   at System.AppDomain.InternalCreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup info)
   at System.AppDomain.CreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup info)
   at Microsoft.Reporting.ReportCompiler.CreateCompilationTempAppDomain()
   at Microsoft.Reporting.ReportCompiler.CompileReport(ICatalogItemContext context, Byte[] reportDefinition, Boolean generateExpressionHostWithRefusedPermissions, ControlSnapshot& snapshot)
   --- End of inner exception stack trace ---
   at Microsoft.Reporting.ReportCompiler.CompileReport(ICatalogItemContext context, Byte[] reportDefinition, Boolean generateExpressionHostWithRefusedPermissions, ControlSnapshot& snapshot)
   at Microsoft.Reporting.LocalService.GetCompiledReport(PreviewItemContext itemContext, Boolean rebuild, ControlSnapshot& snapshot)
   at Microsoft.Reporting.LocalService.CompileReport()
   at Microsoft.Reporting.LocalService.Microsoft.Reporting.ILocalProcessingHost.CompileReport()
   at Microsoft.Reporting.WebForms.LocalReport.EnsureExecutionSession()
   --- End of inner exception stack trace ---
   at Microsoft.Reporting.WebForms.LocalReport.EnsureExecutionSession()
   at Microsoft.Reporting.WebForms.LocalReport.SetParameters(IEnumerable1 parameters)
   at Microsoft.Reporting.WebForms.Report.SetParameters(ReportParameter parameter)

What am I missing. In some posts, it 's been advised to use missing Microsoft.ReportViewer.PorcessingObjectMode.dll. I did that so I have all the required dlls like:

我错过了什么。在某些帖子中,建议使用 missing Microsoft.ReportViewer.PorcessingObjectMode.dll。我这样做了,所以我拥有所有必需的 dll,例如:

-    Microsoft.ReportViewer.Common.dll
-    Microsoft.ReportViewer.WebForms.dll
-    Microsoft.ReportViewer.ProcessingObjectModel.dll

are there.

在那里。

I referred to this post. But still I could not get this done.

我提到了这个帖子。但我仍然无法完成这项工作。

采纳答案by Mil

EDIT:Solution seem to be that the report defintion was not loaded. It can be done for example by

编辑:解决方案似乎是未加载报告定义。它可以通过例如

var reportStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ReportName.rdlc"); 
localReport.LoadReportDefinition(reportStream);


Old suggestion - not applicable here:

旧建议 - 此处不适用:

Honestly, there might be different things. First of all, setting parameters is special. If your projects runs in .NET 4 or higher the reporting engine will run within a different app domain than your application. So you have to set permissions that the parameters can be used. Otherwise it rejects all parameter.

老实说,可能有不同的事情。首先,设置参数比较特殊。如果您的项目在 .NET 4 或更高版本中运行,则报告引擎将在与您的应用程序不同的应用程序域中运行。因此,您必须设置可以使用参数的权限。否则它拒绝所有参数。

var report = new LocalReport();
report.SetBasePermissionsForSandboxAppDomain(new PermissionSet(PermissionState.Unrestricted));

Another issue could be that you are using a different ReportViewer version on your development machine than on the deployment machine.

另一个问题可能是您在开发机器上使用的 ReportViewer 版本与在部署机器上使用的不同。

回答by Dhamu

In my case , In the local environment the report was working but not in staging environment . the reason is , the folder which i published my code doesn't have the .rdlc file itself . That caused this error.

就我而言,在本地环境中,报告可以正常工作,但不能在暂存环境中使用。原因是,我发布代码的文件夹本身没有 .rdlc 文件。这导致了这个错误。

  1. Now I copy pasted the .rdlc file in the appropriate staging folder and it worked .
  1. 现在,我将 .rdlc 文件复制粘贴到适当的暂存文件夹中,并且它起作用了。

or

或者

  1. Before do publish your application , right click on the .rdlc file and goto properties then choose content under Build Action . Then publish the application and check the folder , .rdlc file will be there.

  2. Now move this from your dev environment to other environment.

  1. 在发布您的应用程序之前,右键单击 .rdlc 文件并转到属性,然后在构建操作下选择内容。然后发布应用程序并检查文件夹,.rdlc 文件将在那里。

  2. 现在将其从您的开发环境移至其他环境。

Hope this might help somebody.

希望这可以帮助某人。

回答by URVIL SHAH

The easy way to do it , go into the properties of your

最简单的方法是进入你的属性

".rdlc" file and change the Build Action to "Content "

“.rdlc”文件并将构建操作更改为“内容”

, Copy To Output Directory to "Copy Always " ,

, 复制到输出目录到“始终复制”,

and if you change the version number of "Microsoft.ReportViewer.WebForms" , "Microsoft.ReportViewer.ProcessingObjectModel" , "Microsoft.ReportViewer.Common"

如果您更改了“Microsoft.ReportViewer.WebForms”、“Microsoft.ReportViewer.ProcessingObjectModel”、“Microsoft.ReportViewer.Common”的版本号

make sure you go into the properties and make specific version to be true under property . We explored all the solutions and Finally This worked.

确保您进入 properties 并在 property 下使特定版本为 true 。我们探索了所有的解决方案,最终这奏效了。

回答by Ifesinachi Bryan

I faced the same issue when i deployed an application to azure. After several hours of debugging, i noticed that Microsoft.SqlServer.Types was not the same version with other reporting dlls. Hence you should make sure these dlls are of the same version. Edit their dependency in Web.config as shown below

当我将应用程序部署到 azure 时,我遇到了同样的问题。经过几个小时的调试,我注意到 Microsoft.SqlServer.Types 与其他报告 dll 的版本不同。因此,您应该确保这些 dll 的版本相同。在 Web.config 中编辑它们的依赖项,如下所示

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
        <assemblyIdentity name="Microsoft.ReportViewer.DataVisualization" publicKeyToken="89845dcd8080cc91" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.ReportViewer.Common" publicKeyToken="89845dcd8080cc91" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

回答by Dave Cousineau

For me it was because I hadn't added a reference to the reporting assemblies (Microsoft.ReportViewer.*) to the project.

对我来说,这是因为我没有Microsoft.ReportViewer.*在项目中添加对报告程序集 ( )的引用。

For some reason it worked when running from VS, but running the actual published site would result in this error.

出于某种原因,它在从 VS 运行时有效,但运行实际发布的站点会导致此错误。