This article shows how to deploy a Silverlight application 4 connected to a database. We are going to use IIS 7.5 to do it.
I was stuck a whole week dealing with the following error:
"System.ServiceModel.DomainServices.Client.DomainOperationException: Load operation failed fore query 'GetProducts'.... Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed"
Probably someone else will face it, and that is why I decided to write the solution. Hope it helps!
Let’s imagine that we have finished our Silverlight application using Visual Studio 2010 and the .NET Framework 4. We have a few views and an MDF database in our App_Data folder. It would look like this:
So, let us now deploy our application.
If you are familiar with deploying ASP.NET, then you’ll find this easy to do. So, we’ll right click our web project in the Solution Explorer and let’s click Publish.
This will open up a dialog window. We can create publishing templates. Let’s just choose the location where we are going to publish our application (our computer, a web server, FTP…). I like to check the “delete existing files in the destination folder before publishing” option. Click the Publish button.
Now we are ready to work with the IIS configuration (I'm using Windows 7).
Let’s open the Windows Start Menu, and type “inetmgr” in the search box. The IIS Manager Window will show up.
Go to the MIME Types.
In the appearing list, we’ll need to include the following types (XAML, XAP, XBAP) as shown in the image below:
Now, in the left menu, let’s go to Sites, and let’s add our Web Site (as default site, virtual directory… based on our own needs). When done, let’s click in our application, like this:
In the menu that appears on the right side, we’ll click the “Advance Configuration” link. Now, in the dialog, we’ll click in “Application Group”, and you’ll notice that a button with three dots will appear on its right. Click that button and you will see another dialog. Select ASP.NET v4.0, as shown in the image below:
If ASP.NET v4.0 is not selected, and you leave
DefaultAppPool as I did in the beginning, you will get the following error message every time your application tries to connect with the database: “There is an error in the service with the
So, now that we selected our Application Group, let us configure it. In the left panel (back in the IIS Manager Window), right above our Default Site, we’ll see “Application Groups”. Click it. A list will appear in the center panel. Let’s open the ASP.NET v4.0 and select the right framework version. Click ok and select it again, but instead of opening it, this time we’ll go to the right panel, and we’ll click on “Advance Configuration”:
Change the Local System and select Network Service, as shown in the image above. And that’s it! Now we are able to access our data from our Silverlight 4 application without getting any error from the Web Server.
Hope it helps!
- 14th June, 2010: Initial post