Share via


ADO.NET Data Services Silverlight Project Error : System.IO.FileNotFoundException

Imagine this , you just downloaded the Astoria V1.5 CTP1 and are happily chugging along and decide to make a Silverlight Project
that uses the latest Silverlight client library to make some cool app.
You open an existing Silverlight app  /create a new Silverlight app ,
and generate the client types by running “Add Service Reference” from Visual Studio.
and write some code in the app and hit F5 to run the app .
Now , Instead of seeing the poetic beauty that is a Silverlight app built with Astoria , you see this :

M_D_S_C_Unhandled_Exception

The Exception message is :

System.IO.FileNotFoundException occurred
  Message="Could not load file or assembly 'Microsoft.Data.Services.Client, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
           The system cannot find the file specified."
  StackTrace:
       at SilverlightProject1.Page..ctor()
       at SilverlightProject1.App.Application_Startup(Object sender, StartupEventArgs e)
  InnerException:

 What just happened ?

When the tools which generate the client code for an Astoria Service for Silverlight applications ran , they added a reference to the new client dll,
Microsoft.Data.Services.Client.dll with “Copy Local” set to false.

M_D_S_C_Silverlight_Reference

If your code looks like this,

 public Page(){
InitializeComponent();
nwServiceReference.BlogServiceProvider prov =
                new SilverlightProject1.nwServiceReference.BlogServiceProvider(new Uri("https://ServiceEndPoint"));
}

When the JIT compiler compiles your Page() constructor method, it scans the method, sees that it references a type named BlogServiceProvider , and attempts to load Microsoft.Data.Services.Client.dll so that the reference can be resolved.

Now , Since we set Copy Local to false , the Client DLL is not copied into the XAP file ,and the Silverlight CLR cannot find the file , it throws the above exception.

We can verify by opening the xap file in winrar or some other archiving utility.

Xap_No_CLient_Library

Resolution :

In your Silverlight project, for the reference to “'Microsoft.Data.Services.Client.dll” ,  Set “Copy Local” to “True” and rebuild your Silverlight XAP.

What about “Update Service Reference”?
Same issue , follow same resolution.

When will this be fixed?
We are tracking this issue and will release a fix in a future release of ADO.NET Data Services v1.5

Comments

  • Anonymous
    March 23, 2009
    PingBack from http://www.anith.com/?p=21948

  • Anonymous
    March 24, 2009
    Thank you for submitting this cool story - Trackback from DotNetShoutout

  • Anonymous
    March 29, 2009
    We received a few questions asking if CTP1 of ADO.NET Data Services v1.5 includes a Silverlight library.