Click here to Skip to main content
15,746,302 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I have a small project in VS2010. While generating the rdlc report I wish to access it from assembly or resx file. Is it possible?

My intention is to load the report from my project itself, because it will be embeded with EXE. Therefore the original rdlc is not required to keep with enduser systems.

Thanks For The Helps

From the below code ImageResources is the Resx file name.
Report_DeliveryNote is report name. I tried like the below manner...need to alter

Reflection.Assembly TxAssembly = Reflection.Assembly.GetExecutingAssembly();
String TxResName = TxAssembly.GetName().Name + ".ImageResources";
ResourceManager Tx_ResourceManager = (new Resources.ResourceManager(TxResName,TxAssembly));
Microsoft.Reporting.WinForms.Report MyRept =(safe_cast<Microsoft.Reporting.WinForms.Report>(Tx_ResourceManager.GetObject("Report_DeliveryNote")));


Thanks Again
Updated 30-Jun-14 20:49pm
George Jonsson 1-Jul-14 3:11am    
Have you set the build action of the report to Embedded Resource?
(I assume it is part of your solution)
Paramu1973 1-Jul-14 3:31am    
Hi George, nope. Actually I need in Visual C++ . There is no Build Action property. Therefore trying from C# in this method

1 solution

I hope this will help you:

Reflection.Assembly TxAssembly = Reflection.Assembly.GetExecutingAssembly();
// Full path to your report files with folders: Reports\MyReport.rdlc = Reports.MyReport.rdlc
Stream stream = TxAssembly.GetManifestResourceStream("Reports.MyReport.rdlc");


reportViewer1.LocalReport.ReportEmbeddedResource = "Reports.MyReport.rdlc";

Important is full path to your report file within EXE file.
Share this answer
Paramu1973 1-Jul-14 4:01am    
Thanks, I believe Iam nearer to the solution
I don't have seperate Reports folder, Therefore I gave
Stream stream = TxAssembly.GetManifestResourceStream("MyReport.rdlc");

Then the following error I got.
Arguement Null Exception, Value cannot be null. Parameter name report.
Marcin Kozub 1-Jul-14 4:13am    
You are getting ArgumentNullException probably because the report was not found and stream is NULL. Did you tried to use your report name?

Stream stream = TxAssembly.GetManifestResourceStream("Report_DeliveryNote.rdlc");
Paramu1973 1-Jul-14 4:19am    
Thanks Marcin Kozub. Yah... I tried the same manner , and got the error

"Arguement Null Exception, Value cannot be null, parameter name report.
use the new keyword to create an object instance"

Thanks AGain
Marcin Kozub 1-Jul-14 4:37am    
It's still means that your report wasn't found. Are you sure you embedded report in Exe file? Maybe there is something wrong with report path.
Put this code in your Program.cs file at Main method start:

using (var sw = new StreamWriter(@"D:\resources.txt"))
var assembly = System.Reflection.Assembly.GetExecutingAssembly();
foreach (var resource in assembly.GetManifestResourceNames())

It will list all resources of your project to file D:\resources.txt. You can change the name of file if you want.
Then check if there is your report on this list. If yes, copy exact path to it and try again. If no, you have an answer :)
Paramu1973 1-Jul-14 6:37am    
Hi Marcin, Thanks for your time. The below is full path and available inside my project folder.

"C:\Documents and Settings\Paramu\my documents\visual studio 2010\Projects\My_Applications\My_Applications\Report_DeliveryNote.rdlc"

Thanks Again

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