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

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

相关内容

热门资讯

透视工具!wepoker免费脚... 透视工具!wepoker免费脚本(透视)wepoker免费钻石(本来有脚本)-哔哩哔哩1、wepok...
透视脚本!wepoker免费辅... 透视脚本!wepoker免费辅助器(透视)wepoker智能辅助插件(一贯真的有辅助器)-哔哩哔哩1...
透视工具!aapoker怎么控... 透视工具!aapoker怎么控制牌(透视)aapoker透视插件(真是真的有透视)-哔哩哔哩1、点击...
透视软件!hhpoker是正品... 透视软件!hhpoker是正品吗(透视)hhpoker有后台操作吗(本来一直都是有辅助器)-哔哩哔哩...
透视脚本!hhpoker免费透... 透视脚本!hhpoker免费透视脚本(透视)hhpoker可以控制牌吗(本来是真的有透视)-哔哩哔哩...
透视神器!wepoker插件功... 您好,wepoker插件功能辅助器这款游戏可以开挂的,确实是有挂的,需要了解加去威信【4852750...
透视技巧!wepoker辅助器... 透视技巧!wepoker辅助器是真的吗(透视)wepoker有辅助吗(本来是有挂)-哔哩哔哩wepo...
透视软件!wepoker软件安... 透视软件!wepoker软件安装包(透视)hhpoker万能辅助器(本来是真的有挂)-哔哩哔哩1、在...
透视app!wpk软件是正规的... 透视app!wpk软件是正规的吗(透视)wpk透视工作室(一贯真的是有透视)-哔哩哔哩进入游戏-大厅...
透视攻略!德普之星有透视辅助吗... 透视攻略!德普之星有透视辅助吗(透视)德普之星私人局透视(确实真的有脚本)-哔哩哔哩亲,关键说明,德...