首页 > 解决方案 > 错误无法从程序集“dotless.Core,版本=1.5.3.0”加载类型“dotless.Core.configuration.WebConfigConfigurationLoader”

问题描述

我正在使用 asp.net MVC 应用程序(.net framework 4.6.1),我想将包用于.less文件,所以我在BundleConfig文件中注册包,如下所示

public static void RegisterBundles(BundleCollection bundles)
{
   //other bundles are here ..
    bundles.Add(new LessBundle("~/Content/less").Include("~/Content/*.less"));
}

为了使用less我已经从包管理器安装了以下包

dotless.Core.1.6.0.1
dotless.AspNetHandler.1.6.0.1
System.Web.Optimization.Less.1.3.4

这是我的“_Layout.cshtml”

<!DOCTYPE html>
<html style=" height: 100%;
  margin: 0;">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>@ViewBag.Title - My ASP.NET Application</title>
    @Styles.Render("~/Content/css")
    @Styles.Render("~/Content/less")
    @Scripts.Render("~/bundles/modernizr")
</head>
<body style="padding:0;margin:0;" class="col-12 h-100">
    <div class="h-100 border">
        @RenderBody()
    </div>
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
</body>
</html>

现在当我运行应用程序时,出现以下错误 @Styles.Render("~/Content/less")

System.TypeLoadException:'无法从程序集'dotless.Core,Version = 1.5.3.0,Culture = Neutral,PublicKeyToken = 96b446c9e63eae34'加载类型'dotless.Core.configuration.WebConfigurationLoader'。'

在此处输入图像描述

我搜索了这个错误并得到了dotless: Don't upgrade your dotless if you use System.Web.Optimization.Less已经遇到此问题的链接,但即使按照他们的建议,我仍然遇到同样的错误。

如果有人已经遇到此问题,请提供帮助。

标签: c#asp.net-mvcdotlesssystem.web.optimization

解决方案


似乎System.Web.Optimization.Less仍然希望WebConfigConfigurationLoaderdotless.Core程序集中,它不是dotless 1.6(它已被移动到新dotless.AspNet程序集)。

我恢复到dotless 1.5.2,现在一切正常。


推荐阅读