{"id":1533,"date":"2009-12-01T11:13:01","date_gmt":"2009-12-01T11:13:01","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/odatateam\/2009\/12\/01\/using-the-silverlight-4-0-wcf-data-services-client-library\/"},"modified":"2018-09-04T18:01:51","modified_gmt":"2018-09-04T18:01:51","slug":"using-the-silverlight-4-0-wcf-data-services-client-library","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/odata\/using-the-silverlight-4-0-wcf-data-services-client-library\/","title":{"rendered":"Using the Silverlight 4.0 WCF Data Services Client Library"},"content":{"rendered":"<p>Recently Microsoft released Silverlight 4 Beta which includes an update to the Data Services Silverlight client. The update includes most of the new features previewed in the ADO.NET Data Services CTP2 &#8211; see <a href=\"http:\/\/blogs.msdn.com\/astoriateam\/archive\/2009\/08\/31\/ado-net-data-services-v1-5-ctp2-now-available-for-download.aspx\">this<\/a> blog post for a complete list of the features in CTP2. The new Silverlight 4.0 Data Services client library also includes improvements to the databinding feature to make binding in an asynchronous environment easier and enhanced support for cross-domain calls in Silverlight.<\/p>\n<p>The Silverlight 4.0 beta can be downloaded <b><a href=\"http:\/\/www.silverlight.net\/getstarted\/silverlight-4-beta\/\">here<\/a> &#8211; <\/b>Silverlight 4.0 is designed to be used with Visual Studio Beta 2 only which can be downloaded <b><a href=\"http:\/\/msdn.microsoft.com\/en-us\/vstudio\/dd582936.aspx\">here<\/a><\/b>.<\/p>\n<p><b>Using the SL4 Beta Client in Visual Studio 2010 Beta 2<\/b><\/p>\n<p>Using the Visual Studio 2010 Beta 2 <b>Add Service Reference<\/b> feature with the Silverlight 4.0 beta requires a few extra steps from the normal process \u2013 these steps are only necessary for Visual Studio Beta 2 and will not be necessary in the RTM version of Visual Studio 2010. The following steps assume that you have setup your data service and created your Silverlight application \u2013 if you are new to Silverlight and Data Services you can follow the directions <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/cc838239(VS.95).aspx\">here<\/a> to create your SL application.<\/p>\n<p>Once you have the service and Silverlight application created, the first step is to add a service reference from the Silverlight client. Right-click the Silverlight application project in the <b>Solution Explorer<\/b> and select <b>Add Service Reference\u2026<\/b> Fill in the address of the service root, enter a namespace for the service reference and click <b>OK<\/b>.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/23\/2019\/02\/clip_image002_2.jpg\"><img decoding=\"async\" style=\"border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px\" title=\"clip_image002\" border=\"0\" alt=\"clip_image002\" src=\"https:\/\/devblogs.microsoft.com\/odatateam\/wp-content\/uploads\/sites\/23\/2009\/12\/clip_image002_thumb.jpg\" width=\"244\" height=\"229\" \/><\/a><\/p>\n<p>The service reference will be created. Press <b>F6 <\/b>to compile the project \u2013 you will see some compilation errors in the service reference. At this point, you have to perform a couple of extra steps to resolve the compilation errors.<\/p>\n<p><b>Steps:<\/b><\/p>\n<p>In the <b>Solution Explorer <\/b>click the <b>Show All Files <\/b>button.<\/p>\n<p><b><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/23\/2019\/02\/clip_image004_2.jpg\"><img decoding=\"async\" style=\"border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px\" title=\"clip_image004\" border=\"0\" alt=\"clip_image004\" src=\"https:\/\/devblogs.microsoft.com\/odatateam\/wp-content\/uploads\/sites\/23\/2009\/12\/clip_image004_thumb.jpg\" width=\"144\" height=\"244\" \/><\/a><\/b><\/p>\n<p>A small gray arrow will now be displayed next to your service reference. Expand your service reference, and then expand the Reference.datasvcmap file. Double-click the Reference.cs file that is within the Reference.datasvcmap file node in the solution explorer to open the service reference code.<\/p>\n<p>In the errors output window of Visual Studio, you will see number of errors in this file like the one shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/23\/2019\/02\/clip_image006_2.jpg\"><img decoding=\"async\" style=\"border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px\" title=\"clip_image006\" border=\"0\" alt=\"clip_image006\" src=\"https:\/\/devblogs.microsoft.com\/odatateam\/wp-content\/uploads\/sites\/23\/2009\/12\/clip_image006_thumb.jpg\" width=\"597\" height=\"86\" \/><\/a><\/p>\n<p>To resolve these errors, for each entity type in your service, you need to perform a search and replace in the reference.cs file. Search for (being sure, when searching to replace entitytypename with the name of the entity type you are searching for):<\/p>\n<blockquote>\n<p>System.Data.Services.Client.DataServiceCollection.Create&lt;<i>EntitySetName<\/i>&gt;();<\/p>\n<\/blockquote>\n<p>And replace each instance found with:<\/p>\n<blockquote>\n<p>new System.Data.Services.Client.DataServiceCollection&lt;<i>EntitySetName<\/i>&gt;(null, System.Data.Services.Client.TrackingMode.None);<\/p>\n<\/blockquote>\n<p>Press <b>F6<\/b> to compile; the error message should now be gone. If you update the service reference you will need to repeat these steps.<\/p>\n<p>&#160;<\/p>\n<p>Shayne Burgess<\/p>\n<p>Program Manager, Data Services, Microsoft<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently Microsoft released Silverlight 4 Beta which includes an update to the Data Services Silverlight client. The update includes most of the new features previewed in the ADO.NET Data Services CTP2 &#8211; see this blog post for a complete list of the features in CTP2. The new Silverlight 4.0 Data Services client library also includes [&hellip;]<\/p>\n","protected":false},"author":512,"featured_media":3253,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1533","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-odata"],"acf":[],"blog_post_summary":"<p>Recently Microsoft released Silverlight 4 Beta which includes an update to the Data Services Silverlight client. The update includes most of the new features previewed in the ADO.NET Data Services CTP2 &#8211; see this blog post for a complete list of the features in CTP2. The new Silverlight 4.0 Data Services client library also includes [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/posts\/1533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/users\/512"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/comments?post=1533"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/posts\/1533\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/media\/3253"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/media?parent=1533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/categories?post=1533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/odata\/wp-json\/wp\/v2\/tags?post=1533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}