Question

In my WPF caliburn.micro application, I use ComponentOne's C1DocumentViewer to display a report.

I created in the project a new Folder “Reports” and placed the .xml there. I show the report using C1DocumentViewer. When provide the absolute path to the .xml file, it works fine. But of course I need to use a relative path. So if I make it “../../MyProject/Reports/MyReport.xml”, it works on my machine when I run it in Visual Studio. But not when I publish it using ClickOnce, it just cannot find the file. Same thing if I use “/Reports/MyReport.xml” or “Reports/MyReport.xml”. When I try to use “Reports/MyReport.xml” when I debug in Visual Studio, it is looking for the path “Reports/MyReport.xml” in bin/Debug of the main project of the solution.

Please help. Here is my code:

        protected override void OnViewLoaded(object view)
    {
        base.OnViewLoaded(view);

        var rpt = new C1.C1Report.C1Report();

        rpt.Load(@"Reports/MyReport.xml", "Recent Files Information");

        rpt.DataSource.RecordSource = "MyReportProc(1)";
        rpt.Render();
        Report = rpt.FixedDocumentSequence;
    }
Was it helpful?

Solution

Just a guess. Your problem might be related to the working directory of your process.

When the process refers to a file using a simple file name or relative path (as opposed to a file designated by a full path from a root directory), the reference is interpreted relative to the current working directory of the process.

Check it with Directory.GetCurrentDirectory() when you run your program in Visual Studio and also when you run it after publishing it with ClickOnce.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top