Unity cannot load file or assembly of dependency

Oct 2, 2008 at 10:02 PM
Edited Oct 2, 2008 at 10:03 PM
Ok, new to Unity and trying to understand things... and hit a snag along the way.

I followed some online examples to get Unity working with WCF.  When I hit the SVC file with a browser I get "Could not load file or assembly..." error.

ServiceProject references BusinessProject
BusinessProject  has this:
IDAL dal = container.Resolve<IDAL>();

BusinessProject references InterfacesProject
IDAL is defined in InterfacesProject

DAL1Project defines one implementation of IDAL
DAL2Project defines a second implementation of IDAL

BusinessProject does NOT reference either the DAL1Project or DAL2Project, because it references (and uses) the IDAL project.  (is this wrong? should it reference both DAL1 and DAL2 projects because we don't know which will be used until runtime?)

The missing assembly is DAL1Project.dll.  When I build the solution, everything is fine.  However the DAL1Project.dll is not copied into the ServiceProject /bin folder, which makes sense, because no references exist.  If I manually copy the DAL1Project.dll file into the /bin folder of the ServiceProject, the service seems to work.

Then I tried adding a reference:
BusinessProject references InterfacesProject AND DAL1Project.  (with configuration pointing IDAL to DAL1Project implementation)

DAL1Project.dll is copied to the /bin of BusinessProject, but still not copied to the ServiceProject /bin, so my problem still exists until I manually copy the DAL1Project.dll file into the /bin of ServiceProject.

What am I doing wrong?


Oct 3, 2008 at 10:49 AM
Have all of your project's build to the same BIN folder :)   Then you can maintain the integrity of your projects.   Note: The only time I set references (for the sake of the copy) is on Click-Once deployments - simplifies life greatly.
Oct 3, 2008 at 12:51 PM
Ok, so I was correct in not wanting to set references to the dynamically injected assemblies.  That makes sense.

Thanks.