类型或名称空间名称"Optimization"在名称空间"System.Web"中不存在 [英] The type or namespace name 'Optimization' does not exist in the namespace 'System.Web'

查看:112
本文介绍了类型或名称空间名称"Optimization"在名称空间"System.Web"中不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将一个新网站部署为我的主要网站,并且效果很好.

I am deploying a new website as my main site and it works beautifully.

除根目录外,我所有在根url下的应用程序都可以正常工作.这是一个使用率很高的旧系统(c#.net),不幸的是,我无法访问源代码.

All of my applications under the root url work as well, except for one. It is a legacy system (c#.net) that is heavily used and unfortunately, I do not have access to the source code.

当我运行旧版应用程序www.mysite.com/crm时,出现以下错误:

When I run the legacy application www.mysite.com/crm I get the following error:

Server Error in '/crm' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to 
service this request. Please review the following specific error details and modify 
your source code appropriately. 

Compiler Error Message: CS0234: The type or namespace name 'Optimization' does not 
exist in the namespace 'System.Web' (are you missing an assembly reference?)

Source Error:


Line 17:     <pages>
Line 18:       <namespaces>
Line 19:         <add namespace="System.Web.Optimization" />
Line 20:       </namespaces>
Line 21:     <controls>

Source File: e:\WebSites\newsite\Web.config    Line: 19 


Show Detailed Compiler Output:

Show Complete Compilation Source:


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18446

该错误列出了主要站点的web.config,可以正常工作.但是,只有在主站点下运行该应用程序时,这种情况才会发生.

The error is listing the web.config for the main site, which works. However, it happens only when I run the application under the main site.

它在Server 2008 R2和IIS7上运行

This is running on Server 2008 R2 and IIS7

我该如何纠正?我还能尝试什么?

How do I correct this? What else can I try?

UDPDATE

我不知道它是否有作用,但是错误中引用的Web.Config是针对新网站的,而不是针对旧版应用程序的.我不确定为什么主站点配置是一个因素.

I don't know if it makes a difference, but the Web.Config it references in the error is for the new website, not for the legacy application. I am not sure why the main site config is a factor at all.

澄清

我无权访问旧版应用程序的源代码,因此无法调整该应用程序的属性.将Optimization dll粘贴到站点中也无法修复它.它可能适用于其他用户,但不适用于我.

I don't have access to the source code of the legacy application so I cannot adjust the properties for that application. Pasting the Optimization dll into the site didn't fix it either. It may work for other users, but not for me.

周围的工作

我将新站点设置在另一个URL下,并将流量重定向到根URL到新URL,并允许旧版应用程序按原样运行,直到我们可以替换它为止.很草率的解决方案,但它现在可以使用.

I setup the new site under another URL and redirect traffic to the root URL to the new URL and allow the legacy application to run as is until we can replace it. Very sloppy solution, but it works for now.

推荐答案

我现在刚刚面对这个问题:

I just faced this issue now:

我重新安装了优化框架,并且一切正常:

I reinstalled the optimization framework and everything worked fine:

Install-Package Microsoft.AspNet.Web.Optimization

这篇关于类型或名称空间名称"Optimization"在名称空间"System.Web"中不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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