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容器并将其设置为容器解析器。

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

相关内容

热门资讯

第9分钟绝活儿!红龙poker... 第9分钟绝活儿!红龙poker作必弊指令(透视)竟然存在有辅助工具(哔哩哔哩)一、红龙poker作必...
第3分钟办法!哈糖大菠萝破解器... 第3分钟办法!哈糖大菠萝破解器(透视)总是是有辅助教程(哔哩哔哩)1、进入到哈糖大菠萝破解器是否有挂...
四分钟步骤!wejoker辅助... 四分钟步骤!wejoker辅助软件视频(透视)确实存在有辅助神器(哔哩哔哩)进入游戏-大厅左侧-新手...
6分钟攻略!wejoker辅助... 6分钟攻略!wejoker辅助软件(透视)都是是真的有辅助透视(哔哩哔哩)wejoker辅助软件辅助...
第五分钟指南书!hhpoker... 第五分钟指南书!hhpoker免费透视脚本(透视)其实是真的有辅助教程(哔哩哔哩)1)hhpoker...
第九分钟绝活!wepoker有... 第九分钟绝活!wepoker有没有机器人(透视)一贯是有辅助教程(哔哩哔哩)1、wepoker有没有...
第9分钟讲义!wepoker透... 第9分钟讲义!wepoker透视底牌脚本(透视)总是真的是有辅助透视(哔哩哔哩)1、许多玩家不知道w...
四分钟大纲!epoker免费透... 四分钟大纲!epoker免费透视脚本(透视)竟然是真的有辅助下载(哔哩哔哩)1、任何epoker免费...
第二分钟指南!wepoker免... 第二分钟指南!wepoker免费透视脚本(透视)都是是有辅助透视(哔哩哔哩)1、许多玩家不知道wep...
9分钟办法!pokermast... 9分钟办法!pokermaster破解版(透视)原来是真的有辅助辅助(哔哩哔哩)1、pokermas...