I think that the proposal AllClasses.FromAssemblies(Assembly.GetExecutingAssembly()) proposed above will work only when you have WebAPI as the only project, if your business logic and data access are present in different assemblies, this may not work. as was expected.
I ran into the same problem with the AllClasses.FromAssembliesInBasePath() method in Unity.
Refer to the code provided in the following location:
Unity Framework Project: Unity.RegistrationByConvention
File: AllClasses.Desktop.cs
Method: GetAssembliesInBasePath
Line: 59
basePath = AppDomain.CurrentDomain.BaseDirectory;
This sets the basePath value to the root of the project \ WebAPIProject \ instead of pointing to the bin folder.
If we set basePath as shown below, it will return the path accordingly.
basePath = AppDomain.CurrentDomain.RelativeSearchPath ?? AppDomain.CurrentDomain.BaseDirectory;
I'm not sure if this requires a fix in the Unity Framework, saying that in order to get the job to work properly, the relative search path was convenient in my case.
I distracted the code from Unity to rewrite the AllClasses class with the fix mentioned above.

Srihari Sridharan Oct 29 '14 at 7:14 2014-10-29 07:14
source share