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

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

相关内容

热门资讯

透视要领!wejoker辅助机... 透视要领!wejoker辅助机器人(HHpoker教程)其实真的是有辅助插件(哔哩哔哩)wejoke...
透视攻略!拱趴大菠萝机器人(H... 透视攻略!拱趴大菠萝机器人(HHpoker插件)其实真的是有辅助技巧(哔哩哔哩)1、每一步都需要思考...
透视讲义!wepoker可以开... 透视讲义!wepoker可以开透视吗(HHpoker脚本挂)总是是有辅助教程(哔哩哔哩)1、wepo...
透视操作!xpoker透视辅助... 透视操作!xpoker透视辅助(HHpoker有辅助)本来是真的有辅助脚本(哔哩哔哩)1、打开软件启...
透视学习!红龙poker辅助平... 透视学习!红龙poker辅助平台(WePoKer看底牌)一直有辅助方法(哔哩哔哩)1.红龙poker...
透视方针!hhpoker俱乐部... 透视方针!hhpoker俱乐部是干嘛的(HHpoker辅助挂)一贯真的是有辅助教程(哔哩哔哩)1、每...
透视指南!德扑之心免费透视(W... 透视指南!德扑之心免费透视(WePoKer用挂)好像真的是有辅助攻略(哔哩哔哩)小薇(辅助器软件下载...
透视方式!pokemmo脚本辅... 透视方式!pokemmo脚本辅助(WePoKer私人局)本来是真的有辅助软件(哔哩哔哩)1、poke...
透视绝活!HH平台挂(AApo... 透视绝活!HH平台挂(AApoker控制牌)一直真的是有辅助技巧(哔哩哔哩)1)HH平台挂辅助插件:...
透视步骤!wepoker透视苹... 透视步骤!wepoker透视苹果系统(德普之星私人局)总是是真的有辅助app(哔哩哔哩)1、很好的工...