使用“无功”升级到Visual Studio 2010中后的错误 [英] Error using 'var' after upgrading to Visual Studio 2010

查看:142
本文介绍了使用“无功”升级到Visual Studio 2010中后的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们刚刚从VS2008升级到VS2010



我们的项目编译罚款;但是,当我们去运行Web应用程序,我们在打开的Default.aspx时收到以下错误:




在'/'Application Server的错误。
编译错误说明:维修本
请求所需要的资源的编译
的过程中出现
错误。请查看以下
特定错误详细信息并适当地修改
源代码



编译器错误信息:CS0246:在
型或命名空间名称变种无法
中(是否缺少使用
指令或程序集引用?)




开放的页面,然后将鼠标移至VAR声明,VS2010正确地识别出它的类型是一个正则表达式。



我在想什么时髦的可能发生在我们任何升级过程中的web.config或machine.config中。



任何人遇到这个问题之前? 。任何帮助将不胜感激,希望这能救我一些时间深入到这些文件



编辑:
这里的培训相关代码节的吹了起来:

  10号线:保护无效valSearchFreeText_ServerValidate(对象源,ServerValidateEventArgs参数)
线11 :{
第12行:VAR URL =新的正则表达式(@HTTP(S)://([\w-] + \)+ [\w-] +(/ [\ W- ./?%&=]*),RegexOptions.IgnoreCase)?;
线13:VAR HTML =新的正则表达式(@[<,>],RegexOptions.IgnoreCase);
线14:args.IsValid = html.IsMatch(args.Value)及和放大器; !url.IsMatch(args.Value);



我不认为.NET 4.0的原因;我们只能从VS2008到VS2010升级;我们没有迁移从.NET 3.5到.NET 4.0



我会仔细检查ASP.NET开发服务器与IIS上回来后与几分钟结果从。这肯定正在从开发服务器抛出。



编辑2
这是正在同时从开发服务器和IIS抛出。
System.Xml.Linq的也包括在我们的web.config中的装配部分:

 <添加组件=System.Xml.Linq的,版本= 3.5.0.0,文化=中性公钥= B77A5C561934E089/> 


解决方案

检查您的web.config文件配置/ system.codedom /编译器/编译器节点。应,确定要使用的编译版本 providerOption 子节点。它应该看起来像< providerOption NAME =CompilerVersionVALUE =V3.5/> 。这听起来像你说2.0,而不是3.5。


We just recently upgraded from VS2008 to VS2010.

Our project compiles fine; but when we go to run the Web Application, we get the following error when opening Default.aspx:

Server Error in '/' 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: CS0246: The type or namespace name 'var' could not be found (are you missing a using directive or an assembly reference?)

Opening up the page, and mousing over the 'var' declaration, VS2010 correctly recognizes that it's type is a RegEx.

I'm thinking something funky might have happened in either our web.config or machine.config during the upgrade.

Anybody else run into this problem before? Any help would be greatly appreciated, hopefully it can save me some time diving into these files.

EDIT: Here's the relevent section of code that's blowing up:

Line 10:    protected void valSearchFreeText_ServerValidate(object source, ServerValidateEventArgs args)
Line 11:    {
Line 12:        var url = new Regex(@"http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?", RegexOptions.IgnoreCase);
Line 13:        var html = new Regex(@"[<,>]", RegexOptions.IgnoreCase);
Line 14:        args.IsValid = !html.IsMatch(args.Value) && !url.IsMatch(args.Value);

I don't believe that .NET 4.0 is the cause; we only upgraded from VS2008 to VS2010; we did not migrate from .NET 3.5 to .NET 4.0

I will double check on the ASP.NET Development Server vs. IIS and post back in a few minutes with the results from that. It's definitely being thrown from the Development Server.

Edit 2 This is being thrown from both the Development Server, and IIS. System.Xml.Linq is also included in the assemblies section of our web.config:

<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

解决方案

Check your web.config file for the configuration/system.codedom/compilers/compiler node. There should be a providerOption child node that determines the compiler version to be used. It ought to look like <providerOption name="CompilerVersion" value="v3.5"/>. It sounds like yours says 2.0 instead of 3.5.

这篇关于使用“无功”升级到Visual Studio 2010中后的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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