Информация об изменениях

Сообщение Что не нравится Unity? от 26.09.2019 13:27

Изменено 26.09.2019 14:01 senglory

Что не нравится Unity?
Вот код:
protected void Application_Start(object sender, EventArgs e)
        {
            UnityContainer container = new UnityContainer();
            container.RegisterType<IMapper, CustomMapper>();
            container.RegisterType<ISessionLoginInfo, CustomSession>();
            IDateTimeProvider dtp = DateTimeProvider.Current;
            var cc = container.RegisterInstance<IDateTimeProvider>(dtp);
            GlobalConfiguration.Configuration.DependencyResolver = new Unity.WebApi.UnityDependencyResolver(container);
     }


В итоге, на самой последней строке получаю

Server Error in '/' Application.
Could not load type 'Custom.Shared.IDateTimeProvider' from assembly 'Custom.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.TypeLoadException: Could not load type 'RentPayment.Shared.IDateTimeProvider' from assembly 'Custom.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.



Сборка Custom.Shared точно есть, не подписанная, собирается без ошибок и лежит в том же фолдере, что и сборка веб-приложения. Интерфейс IDateTimeProvider и класс DateTimeProvider лежат в сборке Custom.Shared в namespace Custom.Shared.
Что не нравится Unity?
Вот код:
protected void Application_Start(object sender, EventArgs e)
        {
            UnityContainer container = new UnityContainer();
            container.RegisterType<IMapper, CustomMapper>();
            container.RegisterType<ISessionLoginInfo, CustomSession>();
            IDateTimeProvider dtp = DateTimeProvider.Current;
            var cc = container.RegisterInstance<IDateTimeProvider>(dtp);
            GlobalConfiguration.Configuration.DependencyResolver = new Unity.WebApi.UnityDependencyResolver(container);
     }


В итоге, на самой последней строке получаю

Server Error in '/' Application.
Could not load type 'Custom.Shared.IDateTimeProvider' from assembly 'Custom.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.TypeLoadException: Could not load type 'Custom.Shared.IDateTimeProvider' from assembly 'Custom.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.



Сборка Custom.Shared точно есть, не подписанная, собирается без ошибок и лежит в том же фолдере, что и сборка веб-приложения. Интерфейс IDateTimeProvider и класс DateTimeProvider лежат в сборке Custom.Shared в namespace Custom.Shared.