Eclipsed4utoo's Blog
Not Your Ordinary Programmer

Posts Tagged ‘RIA Services’

Silverlight 4 – Publishing Application to Remote Server

Thu ,22/07/2010

This blog post will talk about the steps needed to publish a Silverlight 4 applications that uses WCF RIA Services for communication.  There were a number of issues that I ran into trying to publish, so I decided to do a blog post to keep other’s from having to search and hunt for the fixes.

NOTE:  These steps are for IIS running on Windows Server 2003 SP2.  Steps may be different for other versions of IIS.

1.  First, you will need to fix your web.config file as I have noted in this blog post.  This is not added by default.

2. (Optional) If you are running a .Net 2.0 or .Net 3.5 website on this same server, you will need to create a new AppPool in IIS.  This is required because an AppPool can only run one version of the .Net CLR.  With .Net 4, Microsoft created a new CLR.  Therefore, you will need an AppPool for the .Net 2.0 and .Net 3.5 websites, and an AppPool for the .Net 4 websites.  NOTE:  This may have changed in later versions of IIS.

3.  Next, in Visual Studio 2010, you will need to set a number of the references of the .Web project to Copy to Local.  I had to do it for all of the System.ServiceModel references.  You may not have all of these references, and that is fine.

SLImage4

Then go to the Properties window, and set Copy Local equal to True.

SLImage5

4.  Next, you need to add a new MIME type for both the .XAP extension and the .XAML extension.

Open the IIS Management console.  Drill-down until you get to your domain/default website.  Right-click and click Properties.
SLImage1

Next, go to the HTTP Headers tab, then click on the Mime Types… button.
SLImage2

Now add the two new mime types..
SLImage3

Now simply publish your web project to your server, and you should be ready to go.

NOTE: This blog post does not talk about creating a Virtual Directory or making the Virtual Directory an application.  There are plenty of other blog posts that can walk you through that.  However, make sure the Virtual Directory is set to the AppPool for .Net 4(if it was required for your setup).

WCF RIA Services – Error When Moving Service To Server

Thu ,01/07/2010

I recently tried publishing a WCF RIA Service to my server, and came across an error.  I was using all the latest Windows Phone 7 and RIA Services Tools, and targeting the .Net 4 framework.  However, since I have both .Net 3.5 and .Net 4 installed on my server, I ran into this error…

WCFError1

“System.Configuration.ConfigurationErrorsException: The value for the ‘compilerVersion’ attribute in the provider options must be ‘v4.0′ or later if you are compiling for version 4.0 or later of the .NET Framework. To compile this Web application for version 3.5 or earlier of the .NET Framework, remove the ‘targetFramework’ attribute from the <compilation> element of the Web.config file.”

It threw me for a loop because it worked fine in Visual Studio 2010 when testing on my development PC, but when moving it to the server, it had this problem.

The fix was fairly easy, once I was able to find it.  Basically, you need to add the a section to the web.config that doesn’t get added when adding the RIA Services DomainService to the project.

<system.codedom>
  <compilers>
     <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
       <providerOption name="CompilerVersion" value="v4.0" />
       <providerOption name="WarnAsError" value="false" />
     </compiler>
  </compilers>
</system.codedom>