# Tuesday, April 20, 2010

If you create a Silverlight application using the WCF RIA Services Class library and with the following walkthrough when you try to access the Context for the RIA application (WebContext) it is not there.

Since we did not enabled the WCF RIA Services for the Silverlight application the WebContext class is not generated in the client.

  image

You can verify this by selecting the Silverlight application in the Solution Explorer, click the Show All Files button in the Solution Explorer toolbar and then inspecting the hidden "Generated_Code" folder.

The workaround is to right click on the Silverlight application in the Solution Explorer, select Properties and  temporarily enable the WCF RIA Services by selecting the web project in the WCF RIA Service link.

 image

Then rebuild the solution find and copy the WebContext class in the file [YourServerAssemblyName].g.cs in the afore mentioned folder to a new file WebContext.cs somewhere in the Silverlight application project.

Now right click on the Silverlight application in the Solution Explorer again and select <No Project Set> in the WCF RIA Service link and rebuild again. "Generated_Code" folder content will be removed.

This is kind of a hack and I believe it could be solved if the WCF RIA Services Class Library template will check if the WebContext exists in the Silverlight application and if not exist it will generate it.

Update (4/26/2010)

If you move the WebContext.cs file to the WCF RIA Services library client make sure to update your app.xaml with the following:

<app:WebContext>
            <app:WebContext.Authentication>
                <appsvc:FormsAuthentication
DomainContextType="[TheNamespaceOfYourRIALibrary].AuthenticationContext,
[TheNameOfYourRIAClassAssembly ], Version= [X].0.0.0"/>
                <!--<appsvc:WindowsAuthentication/>-->
            </app:WebContext.Authentication
   </app:WebContext
posted on Tuesday, April 20, 2010 6:56:54 PM UTC  #    Comments [0]
Comments are closed.