处理“非法路径”时C#报告错误 [英] C# reporting error in processing 'illegal path'
问题描述
我正在尝试使用C#进行报告。我正在尝试嵌入我的rdlc文件:
var reportDataSource = new ReportDataSource(ProspectsDataSet,_ allProspects);
ReportViewer.LocalReport.DataSources.Add(reportDataSource);
ReportViewer.LocalReport.ReportEmbeddedResource =SdcDatabase.Modules.EnquiryModule.View.Reports.ProspectsReport.rdlc;
ReportViewer.ZoomMode = ZoomMode.PageWidth;
ReportViewer.RefreshReport();
rdlc文件本身的构建操作设置为嵌入式资源,副本设置为输出目录设置为始终复制。
我已经仔细检查过,我确信这是ReportEmbeddedResource字符串中的正确命名空间。但是当我尝试加载报告时出现此错误:
本地报告处理期间发生错误。报告的定义无效。
报告处理中出现意外错误。Microsoft
.ReportingServices.ReportIntermiedateFormat.Persistence.IntermediateFormatVersion'的类型初始化程序引发了例外。
路径不合法。
我尝试过的事情:
我尝试在路径中切换一些东西,例如用'/'和'\'替换'。'但到目前为止我还没有得到我还尝试使用LocalPath而不是EmbeddedResource,但我又遇到了错误。
我搜索过这个问题但是没找到任何东西到目前为止解决了我的问题。
这应该有所帮助:访问资源在WPF中 [ ^ ]
I am trying to get reporting in C# to work. I'm trying to embed my rdlc file as such:
var reportDataSource = new ReportDataSource("ProspectsDataSet", _allProspects); ReportViewer.LocalReport.DataSources.Add(reportDataSource); ReportViewer.LocalReport.ReportEmbeddedResource = "SdcDatabase.Modules.EnquiryModule.View.Reports.ProspectsReport.rdlc"; ReportViewer.ZoomMode = ZoomMode.PageWidth; ReportViewer.RefreshReport();
The build action on the rdlc file itself is set to embedded resource and the copy to output directory set to copy always.
I have double checked and I'm certain that that is the correct namespace in the ReportEmbeddedResource string. However when I try to load the report I get this error:
An error occurred during local report processing. The definition of the report " is invalid.
An unexpected error occurred in Report Processing. The type initializer for 'Microsoft
.ReportingServices.ReportIntermiedateFormat.Persistence.IntermediateFormatVersion' threw an exception.
The path is not of a legal form.
What I have tried:
I have tried switching a few things around in the path, such as replacing '.' with '/' and '\' but so far I have not been able to get anything to fix this. I have also tried using LocalPath instead of EmbeddedResource but again I come across errors.
I have searched for this issue but haven't found anything to resolve my issue thus far.解决方案This should help: Access Resources in WPF[^]
这篇关于处理“非法路径”时C#报告错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!