I have seen these 3 file types around, though not in the same application. What are they, what is the difference between them and are there any other special extensions to know about?
What's the difference between .shared, .metadata and .partial files in Silverlight RIA applications?
1 Answers
I try to clarify it a little bit.
A code file with the .shared extension gets "copied" to the silverlight client project during compilation. So that you can manage the code on server side, but use the same code on the client side. Here you can find a definition about the SharedCode feature in silverlight.
A code file with the .metadata extension gets normally generated by the "New Domain Service class"-Wizard in Visual Studio when you check the option "Generate associated classes for metadata". This file contains additional metadata information about a class, like ValidationAttributes for the silverlight client. Here´s you can find information about Metadata in WCF RIA Services.
A code files with the .partial extension signals only that this file contains additional partial code (implementation of partial methods, additional methods or properties) for a class. This is normally used, when you are extending a class that is autogenerated by a designer (like Entity Framework).
The only really special extension is .shared, cause theses files are especially handle on compilation. All other extension are only naming conventions for files, to signal what code is inside a file.
Sidenote: What i currently do is that when i implement an interface on a class i define the class as partial and put the interface implementation code in a other code file with the interface name as extension.
Example:
UserListViewModel.cs --> partial class UserListViewModel with the implementation of the viewmodel
UserListViewModel.INavigationAware.cs --> partial class UserListViewModel with the implementation of the INavigationAware interface for the viewmodel.

- 34,674
- 10
- 123
- 155
-
Thankyou, Jehof, for helpful answer. I quite like your convention of organizing your partial classes by interface implementation; I have seen a similar suggestion [here](http://www.riaservicesblog.net/Blog/post/How-to-setup-your-DomainService-using-partial-classes-for-easy-maintenance.aspx) with regard to mitigating the effects of updates to an EF model. – RichC May 06 '11 at 10:22
-
I asked this question because I wanted to change the text in the login form of a ria business application. I expected to apply the Display annotation on a field in a class on the server side and I initially thought I should make the mod in either the User.cs or the User.shared.cs files. I have seen it done in .metadata files before so I looked for one of those too. I ended up changing the Logininfo file on the client. I kind of understand this as the client is the ultimate destination for data annotations but why it wasn't done on the server and projected onto the client eludes me somewhat. – RichC May 06 '11 at 10:43