I tried to incorporate the UnityConifguration library in a MVC3 project, and was getting errors that my mappings weren't found. I used the following code, which is very similar to what I use from StructureMap.
When running the app, the Unity container object didn't have any registrations. After digging into it, and only by comparing StructureMap's source for their AssembliesFromApplicationBaseDirectory() method, I discovered you are only looking in the AppDomain.CurrentDomain.BaseDirectory directory (which is great for desktop apps), but does no good for web apps. The missing piece is additionally looking in AppDomain.CurrentDomain.SetupInformation.PrivateBinPath which is where the assemblies are for web apps.
I tried to incorporate the UnityConifguration library in a MVC3 project, and was getting errors that my mappings weren't found. I used the following code, which is very similar to what I use from StructureMap.
When running the app, the Unity container object didn't have any registrations. After digging into it, and only by comparing StructureMap's source for their
AssembliesFromApplicationBaseDirectory()
method, I discovered you are only looking in theAppDomain.CurrentDomain.BaseDirectory
directory (which is great for desktop apps), but does no good for web apps. The missing piece is additionally looking inAppDomain.CurrentDomain.SetupInformation.PrivateBinPath
which is where the assemblies are for web apps.The work-around is to do the following:
I'm sure others have run into this and it might be nice to bake this into the
UnityConfiguration.AssemblyScanner
class.