获取System.Web.Optimization在剃刀视图类库中工作 [英] Getting System.Web.Optimization to work in a razor view within a class library

查看:198
本文介绍了获取System.Web.Optimization在剃刀视图类库中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建一个模块化MVC4 app,其中每个模块(=区)是一个类库。模型和控制器编译为.dll文件,意见被复制到相应的文件夹中。在运行时,一切工作正常。在设计时有一个恼人的问题留给:当一个类库中编辑的Razor视图时,Visual Studio不承认System.Web.Optimization命名空间

I'm building a modular MVC4 app, where each module (=area) is a class library. Models and controllers compile into the .dll, the views get copied into the appropriate folder. At runtime, everything works fine. At design time there is one annoying problem left: When editing a razor view within a class library, Visual Studio doesn't recognize the System.Web.Optimization Namespace.

The name "Styles" does not exist in the current context.
The name "Scripts" does not exist in the current context.

我尝试添加该组件在根对System.Web /编译部分和内部的web.config:

I tried adding the assembly to the system.web/compilation section in the root and the inner web.config:

<add assembly="System.Web.Optimization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

我试了一下没有具体的版本了。这两种方法都没有解决问题,反而引发一个asp.net运行时错误(在剃刀视图的第一行可见):

I tried it without the specific version, too. Both methods didn't solve the problem, but triggered an asp.net runtime error (visible in the first line of the razor view):

Could not load file or assembly 'System.Web.Optimization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

该组件在项目引用,复制本地设置为真。它也添加为剃刀配置部分命名空间。

The assembly is referenced in the project and 'Copy Local' is set to 'True'. It's also added as a namespace in the razor configuration section.

我怀疑这是一个普遍的问题,我会在未来的其他组件遇到的问题。

I suspect it's a general problem i'll encounter with other assemblies in the future.

编辑:我做了一般设置获得智能感知在类库中的剃刀视图去。一切正常,到目前为止,除了VS2010不承认优化命名空间。

I did the general setup to get Intellisense going in a razor view within a class library. Everything works so far, except that VS2010 doesn't recognize the Optimization Namespace.

推荐答案

我在pre这个错误观点建造在ASP MVC项目
为解决我已经安装了Microsoft.Web.Optimization用的NuGet。

I had this error in pre builded view in asp mvc project for resolve i've installed Microsoft.Web.Optimization with nuget.

从工具菜单,选择库包管理器,然后单击程序包管理器控制台。输入以下命令来更新捆绑和缩小:

From the Tools menu, select Library Package Manager and then click Package Manager Console. Enter the following command to update Bundling and Minification:

Install-Package Microsoft.Web.Optimization -Pre

下面一些additionals http://forums.asp.net/t/1812274.aspx / 1

some additionals here http://forums.asp.net/t/1812274.aspx/1

这篇关于获取System.Web.Optimization在剃刀视图类库中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆