I guess the suggestion above to use AllClasses.FromAssemblies(Assembly.GetExecutingAssembly())
will work only when you have the WebAPI as the only project, if your business logic and data access are present in different assemblies it might not work as expected.
I faced the same issue with AllClasses.FromAssembliesInBasePath()
method in Unity.
Please refer to the code present in the following location:
Unity Framework Project :Unity.RegistrationByConvention
File: AllClasses.Desktop.cs
Method: GetAssembliesInBasePath
Line: 59
basePath = AppDomain.CurrentDomain.BaseDirectory;
This set the value of basePath 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 appropriately.
basePath = AppDomain.CurrentDomain.RelativeSearchPath
?? AppDomain.CurrentDomain.BaseDirectory;
I am not sure if this requires a fix in Unity Framework, having said that, to get things working as expected, the relative search path was handy in my case.
I abstracted code from Unity to rewrite the AllClasses class with the fix mentioned above.