我正在使用 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已经遇到此问题的链接,但即使按照他们的建议,我仍然遇到同样的错误。
如果有人已经遇到此问题,请提供帮助。