views:

515

answers:

1

I have a Silverlight project where functionality is segregated across multiple Silverlight libraries due to the size and complexity of the application. I am having problems figuring what is the best way to decouple the RIA Domain Service that gets generated from the Website project. I need to be able to access data from the other libraries as they will be loaded dynamically into the main Silverlight application as needed.

+1  A: 

I ended up taking the code that gets generated by Visual Studio in the Generated_Code directory of the main Silverlight application and creating multiple Silverlight libraries to separate the Ria DomainContext, the authentication service, entities, and other Domain services that we had written. I then extracted interfaces for the DomainContext, etc and put them in their own library. Using Microsoft's Unity Framework for Silverlight I was then able to decouple all my modules from the main project. All my modules now use the interfaces. There is one IoC container in the main application where I register all of the classes that implement the interfaces and they get injected into the pages as they are instantiated. Not that compliated after all. The only thing to remember is to leave the EnableClientAccess attribute on the Domain Services classes in the server but remove the ASP.Net server project link from the main Silverlight application. I read that they are planning to make this easier in the final release of Ria services/Silverlight 3 since other people have complained about the tight coupling created by the current setup.

RHLopez