Click here to Skip to main content
15,889,931 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 7-Mar-17 22:14pm

1 solution

This should help: Access Resources in WPF[^]
 
Share this answer
 
Comments
DRD94 8-Mar-17 5:20am    
Thanks for your answer Graeme. I have used this technique with Images, do you suggest I use a Uri for the rdlc file too?
Graeme_Grant 8-Mar-17 5:21am    
For any embedded resource actually. :)
DRD94 8-Mar-17 5:25am    
Even though the ReportEmbeddedResource only takes a string? I'm having to do this at the moment (it's still not working): ReportViewer.LocalReport.ReportEmbeddedResource = new Uri("pack://application:,,,/Modules/EnquiryModule/View/Reports/ProspectsReport.rdlc").ToString();
Graeme_Grant 8-Mar-17 5:26am    
It depends if embedded resources are supported for that control.
DRD94 8-Mar-17 5:32am    
It really does not want to work as an embedded resource. I'm going to try my luck with LocalReport.ReportPath to try a new approach.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900