문제

Is there any way to avoid code generation for types that are already referenced when using multiple domains?

Let me explain.


I have an application infrastacture for silverlight application. This infra package includes 3 (RIA) domain services (authentication, logging, service discovery) on the server side - Infra.Web.dll and a silverlight dll - ClientInfra.dll that implements user authentication at the application start and some other base classes (like BaseApp and BaseView) while Infra.Web.dll is defined as WCF RIA Services Link for ClientInfra.dll.

Now I'm developping some demo silverlight application in order to test my infrastructura. I have created the

DemoApp.Web wich refernces the Infra.Web.dll (in order to get the infra services)

and 2 silverlight projects:

DemoApp.Data that defines DemoApp.Web.dll as WCF RIA Services Link in order to get the generated code and refrences ClientInfra.dll

DemoApp that is the actual silverlight application that refernces ClientInfra.dll

The problem is that when I try to use one of the RIA services from the silverlight application I've got an error that the Domain Service classes are defined both in ClientInfra.dll and DemoApp.Data. As far as I understand the problem is the code from Infra.Web.dll has been generated twice: first for ClientInfra.dll, second for DemoApp.Data.

Is there any way to avoid code generation for types that are allready refrenced like in my case where ClientInfra.dll allready has the generated infra services so there is no need to generate it again in DemoApp.Data?

I'll try to make my question more simple. How can I avoid the ria services type generation (in silverlight) of types that have been already generated for my referenced dll? The type generation duplication causes an error CS0433 that the same types are defined in 2 different dll's

I have found out some interesting fact. If I reference the ClientInfra.dll directly from the DemoApp (the silverlight application project) than the data types that have been alresdy generated in ClientInfra.dll are not generated once more. But if I reference the ClientInfra.dll from DemoApp.Data I do get the duplicated types code generation with a compilation warning that the same types are defined both in the referenced dll and in the generated code.

도움이 되었습니까?

해결책

I have found the following in the msdn documentation

Analyze all assemblies either built or referenced by the middle tier project for domain service classes, entity classes, or shared code.

RIA Services checks the existing members before generating the proxy class. Any member that is already defined will not be generated in the proxy class.

That means that my scenario should work as I have expected!

In order to check the code generation process I set the MSBuild project to build output verbosity (Tool->Options->Projects and Solutions->Build and Run) to Normal (instead of default Minimal). Then after the compilation I discovered that the DemoApp.Data project had failed to load ClientInfra.dll that includes already generated proxies. So the generator just ignored it and generated all the classes from the beginning.

I have solved this loading issue and everything works fine now.

다른 팁

I have a similar infrastructure, but I exposed the DomainServices with SOAP and consume the services in other apps, So , I should you to do the same with your projects.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top