Getting rid of compilation warnings in an intrinsic ria service


When you add a Ria Service to your LightSwitch project you will typically get a whole series of compilation warnings. Although these warnings are quite innocent, it can create a mindset to always disregard any warnings when creating a LightSwitch application. That’s no good, because there might be warnings apart from those generated to the injected Ria Service, which might be important. In short, we want these important warnings not to be hidden by the Ria service warnings.

In this article we’ll explore a very easy solution to get rid of these warnings.

First of all, if you are not familiar with Ria Services, consult other articles on my blog.

The following link gives you the easiest way to inject a ria service in your LightSwitch solution via a NuGet package.

What type of warnings are we talking about ?



What is causing these warnings?

Very simple: the fact that we share a code file from the LightSwitch Server project: “ApplicationDataObjectContext.cs”. So, the Ria Service dll contains de facto this code file, which it needs for setting up an entity framework based connection to the LightSwitch intrinsic database.

Since it’s a link, the LightSwitch server project includes also this code file. In fact, the LightSwitch server project is the owner of this file.  Furthermore the LightSwitch server dll has a binary reference to the Ria Service dll. As a results, the LightSwitch server project has two times access to the types in ApplicationDataObjectContext.cs. Once as native types, and once as imported types.

The solution for getting rid of these warnings

Step 1: add a new Windows Class library (.net 4) to your solution

Call this new project “RiaContextHelper”.

This will give following solution setup:


Make sure the new project has following binary references:


Step 2: In the Ria Project, remove the file link to ApplicationDataObjectContext.cs

Just press the delete button, when selecting the file in the solution explorer Glimlach

Step 3: In the RiaContextHelper project, add the file link to ApplicationDataObjectContext.cs

If you are not familiar with adding an existing file to a solution as a link, here we go:

Right click on the RiaContextHelper project in solution explorer and select Add – Existing Item



And then add as link:





What we want: