This is a migrated thread and some comments may be shown as answers.

Exception when using UriReportSource in a c# application: Invalid URI: The format of the URI could not be determined.

2 Answers 374 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Frederic
Top achievements
Rank 1
Frederic asked on 25 Oct 2012, 03:54 PM
Hello,

I have created a simple report using the standalone report designer.
This report is saved as a .trdx file and located in the same folder as my binaries (I initially wanted it to be in a subfolder, but go the same error)

here is my code to generate  a pdf file:

UriReportSource report = new UriReportSource();
report.Uri = "KiwixInterventionSheetActions.trdx";
            
report.Parameters.Add(new Telerik.Reporting.Parameter("CustomerId", customer_id));
            
ReportProcessor reportProcessor = new ReportProcessor();
File.WriteAllBytes(target_filename, reportProcessor.RenderReport("PDF", report, null).DocumentBytes);

When I do the RenderReport, I get the exception message: "Invalid URI: The format of the URI could not be determined."
If I use a different file name, I get another exception saying that the file cannot be found, so this means that the Uri is correctly interpreted at some stage.

If I use a XmLReportSource instead and fill the Xml field from the content of the file by using following code:

XmlReportSource report = new XmlReportSource();
report.Xml = File.ReadAllText("KiwixInterventionSheetActions.trdx");

then it works, but I need to be able to support UriReportSource, because my final application uses sub-reports specified as files. Whne using the XmlReportSource, the main report works, but the pdf contains identical error message for the sub reports.

Thanks in advance

Fred

2 Answers, 1 is accepted

Sort by
0
IvanY
Telerik team
answered on 30 Oct 2012, 10:07 AM
Hello Frederic,

When using one of our ReportViewer controls the base path that relative UriReportSources are resolved against is determined automatically - depending on the technology (WebForms - Virtual Directory, WinForms - Executable path, etc.) However when using the ReportProcessor directly it is up to the developer to provide an UriReportSource with absolute path. Then the directory from that uri will be used as base path and all sub report items may have relative paths - they will be converted to absolute paths using the base path.

Hope this makes sense.

All the best,
IvanY
the Telerik team

HAPPY WITH TELERIK REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

0
Frederic
Top achievements
Rank 1
answered on 30 Oct 2012, 12:47 PM
Thanks for your answer!
Tags
General Discussions
Asked by
Frederic
Top achievements
Rank 1
Answers by
IvanY
Telerik team
Frederic
Top achievements
Rank 1
Share this question
or