C# 错误“语言不支持"迁移到 .Net4 后

C# Error quot;Is not supported by the languagequot; after migration to .Net4(C# 错误“语言不支持迁移到 .Net4 后)

本文介绍了C# 错误“语言不支持"迁移到 .Net4 后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我们的网站从 .Net 3.5 迁移到 4,但遇到了一个非常奇怪的问题.

I'm trying to migration our website from .Net 3.5 to 4 and I'm encountering a very weird issue.

一旦我以 .Net4 为目标,在 3.5 中运行良好的代码就不再存在,这给了我错误

Code that works just fine in 3.5 does not anymore once I target .Net4, giving me the error

该语言不支持xxx".

"xxx is not supported by the language".

TimeZoneInfo tzi = !calendarItem.UseUserTimeZone ? user.Settings.TimeZoneInfo : l.TimeZoneItem.Info;

在该行代码中,错误显示在.TimeZoneInfo"和.Info"两者的类型为System.TimeZoneInfo".

On that line of code the error shows on ".TimeZoneInfo" and ".Info" both of type "System.TimeZoneInfo".

user.Settings.TimeZoneInfo属性的定义是:

public TimeZoneInfo TimeZoneInfo
{
    get { return World.TimeZones[Convert.ToInt32(this[Setting.TimeZoneInfo])].Info; }
    set { this[Setting.TimeZoneInfo] = value.ToTimeZoneItem().Id.ToString(); }
}

l.TimeZoneItem.Info属性的定义是:

public TimeZoneInfo Info
{
    get { return info; }
}

不太清楚这里发生了什么.请在这方面寻求帮助.

Not really sure what's going on here. Need help on that one please.

推荐答案

可能是程序集不一致问题.当我想使用一个为另一个项目创建循环引用的程序集时,我遇到了这个问题.一旦我修复了这个循环引用问题,错误就不再出现了.

It's probably an assembly inconsistency issue. I had this problem when I wanted to use an assembly that created a circular reference with another project. Once I fixed this circular reference issue, the error didn't appear anymore.

这篇关于C# 错误“语言不支持"迁移到 .Net4 后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:C# 错误“语言不支持"迁移到 .Net4 后

基础教程推荐