AutofacMVC程序集加载问题
创始人
2024-11-12 11:30:30
0

如果您使用的是Autofac及其在MVC中的集成,但是在编译过程中遇到“Issue loading Autofac MVC assemblies”问题, 可能是因为您使用的不匹配的版本号。例如,您可能使用了最新的Autofac Core 5.x版本,但是使用的是Autofac ASP.NET MVC 4.x版本,这可能会导致此类问题。

您需要确保使用相同版本的Autofac Core和Autofac ASP.NET MVC组件。您可以使用NuGet包管理器升级或降级这些组件,以确保它们匹配。

下面是一个使用Autofac Core 5.x和Autofac ASP.NET MVC 5.x的示例:

在公共入口处创建Autofac容器:

public class MvcApplication : System.Web.HttpApplication { protected void Application_Start() { // Create the Autofac container builder. var builder = new ContainerBuilder();

    // Register the MVC controllers.
    builder.RegisterControllers(typeof(MvcApplication).Assembly);

    // Register other components.

    // Build the container.
    var container = builder.Build();

    // Set the DependencyResolver.
    DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

    // Register the filters.
    FilterProviders.Providers.Remove(FilterProviders.Providers.OfType().First());
    FilterProviders.Providers.Add(new AutofacFilterProvider());
}

}

在此示例中,使用Autofac.Core和Autofac.Mvc5命名空间中的组件来构建Autofac容器并将其设置为容器解析器。

希望本解决方案对您有帮助!

相关内容

热门资讯

透视解密"wepok... 透视解密"wepoker破解工具"好像存在有辅助器(哔哩哔哩)亲,关键说明,wepoker破解工具透...
透视有挂"wepok... 透视有挂"wepoker作必弊视频"一贯是真的辅助神器(哔哩哔哩)1、不需要AI权限,帮助你快速的进...
透视解迷"hhpok... 透视解迷"hhpoker是内部控制吗"本来真的有辅助脚本(哔哩哔哩)1、透视解迷"hhpoker是内...
透视教你"xpoke... 透视教你"xpoker辅助工具"都是存在有辅助软件(哔哩哔哩)1、透视教你"xpoker辅助工具"都...
透视教你"hhpok... 透视教你"hhpoker有后台操作吗"确实真的是有辅助神器(哔哩哔哩)1、用户打开应用后不用登录就可...
透视推荐"wpk作必... 透视推荐"wpk作必弊是真的吗"切实真的是有辅助工具(哔哩哔哩)1、很好的工具软件,可以解锁游戏的w...
透视关于"德州局透视... 透视关于"德州局透视"真是存在有辅助脚本(哔哩哔哩)1、进入游戏-大厅左侧-新手福利-激活码辅助透视...
透视辅助"wepok... 透视辅助"wepoker养号规律"都是存在有辅助教程(哔哩哔哩)1、首先打开wepoker养号规律辅...
透视总结"wepok... 透视总结"wepoker私人局怎么玩"都是真的有辅助方法(哔哩哔哩)wepoker私人局怎么玩辅助器...
透视解密"hhpok... 透视解密"hhpoker辅助"切实是有辅助脚本(哔哩哔哩)1、这是跨平台的hhpoker辅助轻量版有...