Recently after upgrading to latest Telerik binaries in my Silverlight RIA Service application, I noticed a different behavior in the auto generated code. After searching a lot on the issue, came to know that the RoundtripOriginalAttribute was missing in the entity set.
As we can not add the attribute explicitly in a auto generated file, I had a tough time to find out the solution of this issue. Lately, got the solution which I am going to document it here for you.
If you are already working in Silverlight and RIA Services, you might already know that, there is an auto generated file called “PROJECT_NAME.Web.g.cs” inside the “Generated_Code” folder under your Silverlight client project. The file automatically gets created on every build.
The entities present in this file has an attribute called “RoundtripOriginalAttribute” (most of the cases), but after upgrading to latest Telerik binary version I noticed that the said attribute was automatically removed from the file with the following comment:
“The following attributes were not generated: The attribute ‘System.ComponentModel.DataAnnotations.RoundtripOriginalAttribute’ is not visible in the client project ‘PROJECT_NAME’. Are you missing an assembly reference?”
Actually, the issue was not due to Telerik binaries but a different System binary that RIA Service uses. In my scenario, the latest Telerik.Windows.Controls.ScheduleView.dll assembly is using Telerik.Windows.Control.dll, which again internally uses System.Windows.dll. After adding them one-by-one, my application started misbehaving.
First I thought, it’s due to the assemblies that I updated recently but later I was sure that, it should not be due to the Telerik assemblies that I have upgraded. After doing a hell lot of analysis, found that the System.Windows.dll that I added to the project was causing the issue.
So, what’s the issue? After doing a couple more analysis, I noticed that my System.Windows.dll has the “Copy Local” attribute set to “True” as shown below:
Just to follow a trial and error method to resolve the issue, I changed it to “False”. You won’t believe that just this small change bring back the “RoundtripOriginalAttribute” to the entities in the WCF RIA Service’s auto generated code file and everything started working properly.
Here is how the attribute “Copy Local” will look for System.Windows.dll assembly reference with the value “False”:
And when I rebuild the project, I got the [RoundtripOriginal] attribute set to the key properties of the entity set as stated in the below screenshot:
Not a big deal but finding out the solution was hectic. I spent a big amount of time just to find the issue and the online forum answers didn’t give me a valid result. Thus thought to share the same here, in case you face the same issue, this will help you to resolve the problem quickly by just following the above simple step.
There is a proverb “Nothing is impossible in the world and the word ‘IMPOSSIBLE’ itself says ‘I M Possible’” and this is true. I hope that this post was as useful as my other blog posts and will help you to resolve the RoundtripOriginal attribute issue in your WCF RIA Services project. Let me know, if that helps.