Newbie: How To Get Unity To Look In Specific Directory

Jul 31, 2008 at 8:46 PM
Edited Jul 31, 2008 at 8:47 PM
Hi:

I have a PRISM application with a Modules folder.  Each Module that I load creates a a child container with it's own configuration file.  The problem I have is Unity insists on looking in the current directory of the exe when it configures the child container with the configuration section.  It seems obvious that giving Unity some kind of hint that the module is not in the same folder as the exe should be easy to do.  However even trying to hack in a file path ( which when I check with a command window in the debugger is correct from the current directory ) I can't seem to get Unity to look in my Modules folder so that it can find the module.dll file and resolve the types.  arrgghhhh.... :(

I"m confused this seems like a very straight forward thing to do.  I want Unity to look in a specific folder when trying to resolve types.  As soon as Unity reads the configuration section and tries to load the container with configuration it complains that it can't find the module.  I am using the DirectoryModule loader in PRISM so the module is NOT in the same folder as the exe.

I'm brand new with Unity and have looked for a path property or argument to supply to the container "look in here for libraries to resolve types" but it seems homed on the idea that everything has to live in the same folder as the exe.  Any help would be appreciated.

thanks
markb@iship.com
Jul 31, 2008 at 10:36 PM
This is the nature of .NET configuration. Libraries don't have config files, appdomains do. It is possible to load external config files, but without more details on your issue it's hard to know where to start.

Could you please provide a small sample that demonstrates the problem, along with the error message you're getting?

Aug 5, 2008 at 3:07 PM
Edited Aug 5, 2008 at 3:08 PM
as chris says libraries don't have config files. Unfortunately the VS IDE does allow you to add setting through the properties dialog for a dll(this is pretty naughty as the ammount of times I have had to explain that configs are loaded for the appdomain to other developers is countless)

so you can do two things, copy the config settings from the app.config in your dll project folder and paste them into the master appdomain project console/exe etc or you can programmatically load the config files wherever you are setting up the unity container.

Chris. I'd love to see the config section redirection functionality you get with windsor which enables you to switch out debug/release configs from different file sources by just setting a single setting.