views:

20

answers:

2

Hi,

I am trying to read an XML file in RIA Service and I am getting the following error.

Load operation failed for query 'GetSummaryList'. Could not find a part of the path 'C:\WINDOWS\SYSTEM32\CoreResources\SumaryListDS.xml'.

I am using Silverlight 4 which is using RIA service. I am trying to read the SumaryListDS.xml located in the bin\CoreResources folder. But the application insted of looking for the file under bin\CoreResources, its trying to read it from C:\WINDOWS\SYSTEM32\CoreResources.

I am just wondering how to read a file using relative path in RIA Service with Silverlight front end?

Thanks, Vinod

A: 

You should be able to use .. to go up one directory, such as ../CoreResources/GetSummaryList.xml

Nikhil
A: 

Here is how I resolved my problem. Its been implemented in one of the layers of business tier, which can be used by variety of clients (ASP.NET, Console App, Windows Client, Silverlight hosted inside ASP.NET). So when GetSummaryXml is called, previously it used to be

public DataSet GetSummaryXml()
{
    var dsReport = new DataSet("Report");
    var summaryListXmlPath = "CoreResources/SumaryListDS.xml";
    dsReport.ReadXml(summaryListXmlPath);
    return dsReport;
}

I started getting an error when I started consuming it in RIA Domain Service to be used by Silverlight 4 client.

ERROR:

Load operation failed for query 'GetSummaryList'. Could not find a part of the path 'C:\WINDOWS\SYSTEM32\CoreResources\SumaryListDS.xml'.

But SumaryListDS.xml located in the bin\CoreResources, not WINDOWS\SYSTEM32\CoreResources

So I modified GetSummaryXml to...

public DataSet GetSummaryXml()
{
    var dsReport = new DataSet("Report");
    var currContext = HttpContext.Current;
    var summaryListXmlPath = "CoreResources/SumaryListDS.xml";
    if (currContext != null)
        summaryListSchemaPath = currContext.Server.MapPath(@"../bin/" + summaryListXmlPath);
    dsReport.ReadXml(summaryListXmlPath);
    return dsReport;
}

And now its working fine. I am not sure if this is a perfect solution thou.

Vinod