<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Why Can&#039;t You Code? &#187; ria services</title>
	<atom:link href="http://www.whycantyoucode.com/tag/ria-services/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.whycantyoucode.com</link>
	<description>The highest form of ignorance is when you reject something you don&#039;t know anything about.</description>
	<lastBuildDate>Thu, 25 Feb 2010 14:39:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Verbose steps to migrate a Silverlight application from .NET RIA Services (July 09) to WCF RIA Services (PDC 09)</title>
		<link>http://www.whycantyoucode.com/2009/11/verbose-steps-to-migrate-a-silverlight-application-from-net-ria-services-july-09-to-wcf-ria-services-pdc-09/</link>
		<comments>http://www.whycantyoucode.com/2009/11/verbose-steps-to-migrate-a-silverlight-application-from-net-ria-services-july-09-to-wcf-ria-services-pdc-09/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 19:25:00 +0000</pubDate>
		<dc:creator>Andrei Alecu</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[ria services]]></category>

		<guid isPermaLink="false">http://www.whycantyoucode.com/?p=134</guid>
		<description><![CDATA[These are the steps I had to go through to migrate a Silverlight application that was running on the .NET RIA Services preview released in July 09, to the new WCF RIA Services released during PDC 09:

Delete all HttpHandler references to DataService.axd from your web.config. Basically, these two need to go:
&#60;system.webServer&#62;
  ...
  &#60;handlers&#62;
 [...]]]></description>
			<content:encoded><![CDATA[<p>These are the steps I had to go through to migrate a <strong>Silverlight</strong> application that was running on the .NET RIA Services preview released in July 09, to the new <strong>WCF</strong> RIA Services released during PDC 09:</p>
<ol>
<li>Delete all HttpHandler references to DataService.axd from your web.config. Basically, these two need to go:
<pre class="brush: xml; ruler: true; smart-tabs: false;">&lt;system.webServer&gt;
  ...
  &lt;handlers&gt;
    ...
    &lt;add name=&quot;DataService&quot; verb=&quot;GET,POST&quot; path=&quot;DataService.axd&quot; type=&quot;System.Web.Ria.DataServiceFactory, System.Web.Ria, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35&quot; /&gt;
  &lt;/handlers&gt;
&lt;/system.webServer&gt;</pre>
<pre class="brush: xml; ruler: true; smart-tabs: false;">&lt;httpHandlers&gt;
  ...
  &lt;add path=&quot;DataService.axd&quot; verb=&quot;GET,POST&quot; type=&quot;System.Web.Ria.DataServiceFactory, System.Web.Ria, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35&quot; validate=&quot;false&quot; /&gt;
&lt;/httpHandlers&gt;</pre>
</li>
<li>Add/update your web.config along the lines of:
</p>
<p>.NET 3.5:</p>
<pre class="brush: xml; ruler: true; smart-tabs: false;">&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;configuration&gt;
  &lt;system.web&gt;
    &lt;httpModules&gt;
      &lt;add name=&quot;DomainServiceModule&quot; type=&quot;System.Web.Ria.Services.DomainServiceHttpModule, System.Web.Ria,Version=2.0.0.0,Culture=neutral,PublicKeyToken=31BF3856AD364E35&quot;/&gt;
    &lt;/httpModules&gt;
  &lt;/system.web&gt;
  &lt;system.webServer&gt;
    &lt;modules&gt;
      &lt;add name=&quot;DomainServiceModule&quot; preCondition=&quot;managedHandler&quot; type=&quot;System.Web.Ria.Services.DomainServiceHttpModule, System.Web.Ria,Version=2.0.0.0,Culture=neutral,PublicKeyToken=31BF3856AD364E35&quot;/&gt;
    &lt;/modules&gt;
  &lt;system.webServer&gt;
  &lt;system.serviceModel&gt;
    &lt;serviceHostingEnvironment aspNetCompatibilityEnabled=&quot;true&quot;/&gt;
  &lt;/system.serviceModel&gt;
&lt;/configuration&gt;</pre>
<p>.NET 4.0: </p>
<p></p>
<pre class="brush: xml; ruler: true; smart-tabs: false;">&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;configuration&gt;

  &lt;system.web&gt;
    &lt;httpModules&gt;
      &lt;add name=&quot;DomainServiceModule&quot; type=&quot;System.Web.Ria.Services.DomainServiceHttpModule, System.Web.Ria, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35&quot; /&gt;
    &lt;/httpModules&gt;
    &lt;compilation debug=&quot;true&quot; targetFramework=&quot;4.0&quot; /&gt;
  &lt;/system.web&gt;

  &lt;system.webServer&gt;
    &lt;validation validateIntegratedModeConfiguration=&quot;false&quot;/&gt;
    &lt;modules runAllManagedModulesForAllRequests=&quot;true&quot;&gt;
      &lt;add name=&quot;DomainServiceModule&quot; preCondition=&quot;managedHandler&quot;
          type=&quot;System.Web.Ria.Services.DomainServiceHttpModule, System.Web.Ria, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35&quot; /&gt;
    &lt;/modules&gt;
    &lt;validation validateIntegratedModeConfiguration=&quot;false&quot; /&gt;
  &lt;/system.webServer&gt;

  &lt;system.serviceModel&gt;
    &lt;serviceHostingEnvironment aspNetCompatibilityEnabled=&quot;true&quot; /&gt;
  &lt;/system.serviceModel&gt;
&lt;/configuration&gt;</pre>
</li>
<li>If you’re throwing <strong>DomainServiceException</strong>, take note that the class has been renamed to <strong>DomainException</strong>. Update your code accordingly. </li>
<li>Remove any reference you may have to <strong>System.Web.DomainServices.Providers.dll</strong>, you will need to add a new reference to either <strong>System.Web.DomainServices.EntityFramework.dll</strong> or <strong>System.Web.DomainServices.LinqToSql.dll</strong> depending on what you use. </li>
<li>Change this:
<pre class="brush: csharp; ruler: true; gutter: false; toolbar: false; smart-tabs: false;">using System.Web.DomainServices.LinqToEntities;</pre>
<p>To this:</p>
<pre class="brush: csharp; ruler: true; gutter: false; toolbar: false; smart-tabs: false;">using System.Web.DomainServices.Providers;</pre>
<p>Everywhere.</p>
</li>
<li>The DomainService.<strong>Context </strong>property has been renamed to <strong>ObjectContext</strong>. Update all your code accordingly.
<p>&#160;</p>
<p><strong>Now, your Web application should build, but you may still get this error while building the actual Silverlight application:</strong></p>
<pre>Error    5    The &quot;CreateRiaClientFilesTask&quot; task failed unexpectedly.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---&gt; System.InvalidOperationException: The AutoGenerateField property has not been set.  Use the GetAutoGenerateField method to get the value.
   at System.ComponentModel.DataAnnotations.DisplayAttribute.get_AutoGenerateField()</pre>
<p>In my case, this was a problem with <strong>the System.ComponentModel.DataAnnotations.dll</strong> reference. Remove it and re-add it from the <strong>Global Assembly Cache</strong>. </p>
</li>
<li>Remove the reference to <strong>System.Windows.Ria.Controls.dll </strong>and add one to <strong>System.Windows.Controls.Ria.dll</strong>. </li>
<li>You will need to update your XAML to reference the new assembly:
<p>Replace <strong>System.Windows.Ria.Controls</strong> with <strong>System.Windows.Controls.Ria</strong> in your namespace declarations in the header of the XAML file. Here’s how the old ones look:</p>
<pre class="brush: xml; ruler: true; gutter: false; toolbar: false; smart-tabs: false;">xmlns:riaControls=&quot;clr-namespace:System.Windows.Controls;assembly=System.Windows.Ria.Controls&quot; xmlns:System_Windows_Data=&quot;clr-namespace:System.Windows.Data;assembly=System.Windows.Ria.Controls&quot;</pre>
</li>
<li><strong>RiaContext </strong>(.Current) has been renamed to <strong>WebContextBase</strong>. It’s in the System.Windows.Ria namespace. </li>
<li><strong>The System.Windows.Ria.Data</strong> namespace has been removed. So make sure to remove it from your <strong>usings</strong> also. </li>
<li><strong>RiaContext.Current.User</strong> is now <strong>WebContextBase.Current.Authentication.User</strong> </li>
<li>In XAML, the namespace for the <strong>ControlParameter</strong> type has changed to <strong>System.Windows.Controls</strong> from <strong>System.Windows.Data</strong>, update accordingly. </li>
<li>If you use Forms Authentication, update the <strong>RiaContext</strong> reference in <strong>App.xaml</strong> to a <strong>WebContext</strong> reference such as:
<pre class="brush: xml; ruler: true; smart-tabs: false;">&lt;Application.ApplicationLifetimeObjects&gt;
    &lt;app:WebContext&gt;
        &lt;app:WebContext.Authentication&gt;
            &lt;appsvc:FormsAuthentication/&gt;
            &lt;!--&lt;appsvc:WindowsAuthentication/&gt;--&gt;
        &lt;/app:WebContext.Authentication&gt;
    &lt;/app:WebContext&gt;
&lt;/Application.ApplicationLifetimeObjects&gt;</pre>
</li>
</ol>
<p>With some luck, your project should be migrated to WCF RIA Services now. These were the steps I needed to get mine working.</p>
<p>Additional breaking changes in the new release can be found <a href="http://code.msdn.microsoft.com/RiaServices/Release/ProjectReleases.aspx?ReleaseId=3570" target="_blank">here</a>.</p>
<p>Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.whycantyoucode.com/2009/11/verbose-steps-to-migrate-a-silverlight-application-from-net-ria-services-july-09-to-wcf-ria-services-pdc-09/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Workaround for Silverlight RIA Services DateTime discrepancy between server and client</title>
		<link>http://www.whycantyoucode.com/2009/11/workaround-for-silverlight-ria-services-datetime-discrepancy-between-server-and-client/</link>
		<comments>http://www.whycantyoucode.com/2009/11/workaround-for-silverlight-ria-services-datetime-discrepancy-between-server-and-client/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 12:07:32 +0000</pubDate>
		<dc:creator>Andrei Alecu</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[ria services]]></category>
		<category><![CDATA[workaround]]></category>

		<guid isPermaLink="false">http://www.whycantyoucode.com/?p=125</guid>
		<description><![CDATA[While working on a Silverlight application. I discovered that all the dates displayed in my DataGrid were skewed by a few hours from the real date stored in the database. Upon a closer look I noticed this skew was closely correlated to the time difference between the server’s time zone and the UTC date.
I needed [...]]]></description>
			<content:encoded><![CDATA[<p>While working on a Silverlight application. I discovered that all the dates displayed in my DataGrid were skewed by a few hours from the real date stored in the database. Upon a closer look I noticed this skew was closely correlated to the time difference between the server’s time zone and the <a href="http://en.wikipedia.org/wiki/Coordinated_Universal_Time" target="_blank">UTC date.</a></p>
<p><strong>I needed my Silverlight application to display and use the exact same dates as the database regardless of the time zone my users were in.</strong></p>
<p>Apparently, there’s a little known <span style="text-decoration: line-through">bug</span> “<a href="http://smehrozalam.wordpress.com/2009/08/07/ria-services-how-dates-are-handled-and-sent-across-the-wire/" target="_blank">feature</a>” in the latest <a href="http://silverlight.net/getstarted/riaservices/" target="_blank">RIA Services Beta</a> for Silverlight that involves dates:</p>
<p>RIA uses <strong>JSON</strong> to send data across the wire, and the Microsoft JSON serializers <a href="http://www.west-wind.com/weblog/posts/471402.aspx" target="_blank">always serialize dates as UTC</a>.</p>
<p>Dates retrieved from the database always seem to come up as <code>DateTimeKind.Unspecified</code>, meaning that the serializer will take a guess and treat them as local dates (in the <strong>server’s </strong>local time zone) and convert them to UTC time before sending out on the wire. </p>
<p>There’s an overridable property in the <code>DomainService</code> class called <code>UsesUtcDateTimes</code> which should in theory make the serializer leave your dates alone by treating them as UTC &#8211; which is still not ideal, but it means it won’t change them further &#8211; the property, however, <em>currently </em>doesn’t do anything.</p>
<p><font color="#cc0000" size="4">The gotcha here is that the <strong>original</strong> time zone of the date is <strong>lost</strong> on the wire. It’s not sent along with the date so there’s no way you could determine, on the client, what time zone the date was in originally!</font></p>
<p><strong>Example:</strong> if the server’s timezone is GMT+1, a date of December 21, 2012 <strong><u>12:21 PM</u></strong> will be converted to the UTC (GMT+0) date of December 21, 2012 <strong><u>11:21 AM</u></strong> before being sent out!</p>
<p>The Silverlight application will now display the UTC date of December 21, 2012 11:21 AM instead of the expected date from the database.</p>
<h4><strong>The easy workaround…</strong></h4>
<p>… is to mimic the behavior of the currently un-implemented <code>UsesUtcDateTimes</code> property and fool the serializer into thinking all of your dates are <strong>already</strong> in UTC so it doesn’t mess with them. Thanks to partial classes, you can do this.</p>
<p>Create new partial classes for each of your RIA Data Classes that hold <code>DateTime</code> values and override the <code>On(DateTimePropertyName)Changed()</code> methods like the following:</p>
<pre class="brush: csharp; ruler: true; smart-tabs: false;">public partial class MyDataClass
{
    partial void OnDateChanged()
    {
        _Date = DateTime.SpecifyKind(_Date, DateTimeKind.Utc);
    }

    partial void OnOtherDateChanged()
    {
        _OtherDate = DateTime.SpecifyKind(_OtherDate, DateTimeKind.Utc);
    }
}</pre>
<p>(Notice the <code>partial</code> keyword on the methods as well, not just on the class.)</p>
<h4>The technically correct workaround…</h4>
<p>.. is to pass the original time zone, as a property, along with the <a href="http://en.wikipedia.org/wiki/Coordinated_Universal_Time" target="_blank">UTC</a> DateTime across the wire, and then re-apply the time zone to it on the client before using it.</p>
<p>I’m hoping for a future RIA Services release to address this issue better, and perhaps pass the time zone across by itself.</p>
<h4></h4>
<h3><font color="#cc0000"><strong>UPDATE:</strong> This appears to be fixed in the latest release of </font><a href="http://silverlight.net/riaservices/" target="_blank"><font color="#cc0000">WCF RIA Services</font></a><font color="#cc0000">. This workaround is no longer necessary unless your application still uses the older .NET RIA Services. </font></h3>
<h3><font color="#cc0000">I have written a verbose guide on </font><a href="http://www.whycantyoucode.com/2009/11/verbose-steps-to-migrate-a-silverlight-application-from-net-ria-services-july-09-to-wcf-ria-services-pdc-09/" target="_blank"><font color="#cc0000">upgrading an application to WCF RIA Services</font></a><font color="#cc0000">. Check it out </font><a href="http://www.whycantyoucode.com/2009/11/verbose-steps-to-migrate-a-silverlight-application-from-net-ria-services-july-09-to-wcf-ria-services-pdc-09/" target="_blank"><font color="#cc0000">here</font></a><font color="#cc0000">.</font></h3>
]]></content:encoded>
			<wfw:commentRss>http://www.whycantyoucode.com/2009/11/workaround-for-silverlight-ria-services-datetime-discrepancy-between-server-and-client/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
