在Mvc4中的_Layout.cshtml中的Styles.Render调用上出现WebGrease错误 [英] WebGrease error on Styles.Render call in _Layout.cshtml in Mvc4
问题描述
我正在尝试添加绑定到我的Mvc4 web项目。我采取的步骤:
I'm trying to add bundling to my Mvc4 web project. The steps I took:
- 添加了对我的项目的引用
System.Web.Optimization
- 在
中添加
@ Styles.Render(〜/ Content / css)
;of
_Layout.cshtml
- 添加
BundleConfig.RegisterBundles(BundleTable。 Bundle); 至
Global.asax.cs
- 新增
BundleConfig.cs (〜/ Content / css)添加到
到我的
App_Start
〜/ Content / site.css)); 在我的
内容
文件夹中添加了一个简单的 site.css
。 - Added a reference to my project to
System.Web.Optimization
- Added
@Styles.Render("~/Content/css")
within<head>
of my_Layout.cshtml
- Added
BundleConfig.RegisterBundles(BundleTable.Bundles);
toGlobal.asax.cs
- Added
BundleConfig.cs
to myApp_Start
folder withbundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));
withinRegisterBundles(...)
method - Added a simple
site.css
within myContent
folder.
我从上面步骤#2得到的错误是无法加载文件或程序集'WebGrease,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其一个依赖关系。系统找不到指定的文件。
The error that I get on the line from step #2 above is Could not load file or assembly 'WebGrease, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
我缺少一个DLL引用或者什么?注意,我最初从一个空白的Mvc4项目开始。
Am I missing a DLL reference or something? Note that I started originally from a blank Mvc4 project.
推荐答案
在过去一天左右,找出了一个解决方案。基本上你只需更新webgrease。
Over the last day or so I was having this issue too but I figured out a solution. Basically you need to just update "webgrease".
这是我做了更新webgrease:
Here's what I did to update webgrease:
- 右键单击解决方案资源管理器中的项目解决方案。
- 点击管理NuGet套餐以获取解决方案
- 转到左侧的更新部分
- 搜索WebGrease
- 然后更新WebGrease
- right click your project solution in your solution explorer.
- Click "Manage NuGet Packages for Solution"
- Go to the updates section on the left
- Search "WebGrease"
- Then update "WebGrease"
这篇关于在Mvc4中的_Layout.cshtml中的Styles.Render调用上出现WebGrease错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!