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

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

相关内容

热门资讯

一分钟揭秘!wepokerpl... 一分钟揭秘!wepokerplus辅助,hh poker辅助器先试用,揭秘攻略(一贯是有挂的)-哔哩...
终于清楚!newpoker怎么... 终于清楚!newpoker怎么安装脚本,we-poker软件,力荐教程(一直是有挂的)-哔哩哔哩;1...
揭秘关于!wepoker钻石怎... 揭秘关于!wepoker钻石怎么看底牌,德普之星的辅助工具介绍,必胜教程(一直确实有挂)-哔哩哔哩;...
一分钟揭秘!uupoker有透... 一分钟揭秘!uupoker有透视吗,hhpoker有没有辅助,新2026版(一贯真的有挂)-哔哩哔哩...
科技通报!hhpoker为什么... 科技通报!hhpoker为什么一直输,wepoker透视脚本苹果版,存在挂教程(原来有挂)-哔哩哔哩...
透视辅助!wepokerplu... 透视辅助!wepokerplus透视脚本免费,wepoker辅助插件功能,必备教程(一贯有挂)-哔哩...
透视辅助!wejoker内置辅... 透视辅助!wejoker内置辅助,hhpoker有辅助的吗,wpk教程(其实真的有挂)-哔哩哔哩,h...
一分钟了解!wepoker透视... 一分钟了解!wepoker透视脚本下载,wepoker怎么看牌型,黑科技教程(其实真的是有挂)-哔哩...
推荐十款!约局吧德州有挂吗,w... 推荐十款!约局吧德州有挂吗,wpk私人局辅助是真的吗,规律教程(一直真的有挂)-哔哩哔哩;wpk私人...
分享实测!模拟器打开hhpok... 分享实测!模拟器打开hhpoker,哈糖大菠萝怎么挂,靠谱教程(原来是有挂)-哔哩哔哩相信很多朋友都...