Question about ObjectFactory

Question about ObjectFactory

Old forum URL: forums.lhotka.net/forums/t/9907.aspx


ddredstar posted on Thursday, December 30, 2010

I want to use ObjectFactory to make my Data Access a separate Assemble,

But there is a question, the Business Object project add reference to DataAccess project, on the other hand, the DataAccess project must add reference to Business Object project. So cycle reference happensSad

Anybody help me what should i do, Thanks!!!

JonnyBee replied on Thursday, December 30, 2010

Hi,

The whole concept of ObjectFactory pattern relies in the fact that  BusinessObjects assembly should not have a reference to the DataAccess assembly.

If you need references both ways then look at your code again.

1. The DataAccess assembly must have a reference to your BusinessObjects.

2. Remove reference to DataAccess assembly in you BO project

3. Resolve any leftover issues by restructuring your code.

ddredstar replied on Tuesday, January 04, 2011

If BO project not add reference to DataAccess assembly, an exception thrown says "DataPortal.Fetch failed (Factory type or assembly could not be loaded ..."

I resolved this by adding reference to DataAccess assembly in my Web project(Wcf host project), is this the right way?

JonnyBee replied on Tuesday, January 04, 2011

Yes, you can do it that way or

a) add a copy task to your build script after all assemblies are compiled
or
b) copy the assembly in PostBuild on DataAccess assembly to required output folders.

In all essence - you should not require the DataAcess assembly to exist on the client when you use a remote data portal. You only need the methods that have RunLocal atrribte to be compiled into a DatatAccess assembly on the client IF you use the RunLocal atrribute.

 

ddredstar replied on Wednesday, January 05, 2011

Thank you very much, man!

Copyright (c) Marimer LLC