
I call this class in WebAPI's Startup.cs to initialize DI and it fails in Initialize(), please see the bold line in above code. Var unitySection = (Unit圜onfigurationSection)configuration.GetSection(sectionName) configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None) Var fileMap = new ExeConfigurationFileMap String path = new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase).LocalPath įileName = Path.Combine(Path.GetDirectoryName(path), fileName) Private void RegisterTypes(string fileName, string sectionName) This.RegisterTypes(unityPathValues.Get(unityPathValue), "unity") įrameworkManager.LoggerFactory = () NameValueCollection unityPathValues = ConfigurationManager.GetSection("Unit圜onfigPath") as NameValueCollection įoreach (var unityPathValue in unityPathValues.AllKeys) This.RegisterTypes(executingAppName, "unity") If (System.IO.File.Exists(executingAppName))

String executingAppName = entryAssembly.GetName().Name ĮxecutingAppName = executingAppName + "nfig" Incase of executing from test cases, entry assembly comes as null. If (ConfigurationManager.GetSection("unity") != null)Īssembly entryAssembly = Assembly.GetEntryAssembly() / Initializes a new instance of the DICContainer class. Private readonly IUnit圜ontainer container = new Unit圜ontainer() / Holds the reference of unity container. The DIContainer class internal class DICContainer : IObjectFactory, IDisposable Public static IObjectFactory ObjectFactory Private static IObjectFactory objectFactory = new DIContainer() / Holds the reference of object factory. I have a static FrameworkManger class public static class FrameworkManager cs file in this class library which I use to initialize the Unity DI. I have a class library by name Coreadded as well. Try to initialize the classes of class libraries in WebAPI 's Startup.cs via Unity it fails. I reference this class library in WebAPI project. I have added some class libraries project as well.

I have a solution in which I have ASP.NET 5 WebProject (webAPI) project.
