迁移到 .Net4 后出现 C# 错误 "Is not supported by the language"

标签 c# .net migration

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

一旦我以 .Net4 为目标,在 3.5 中工作得很好的代码就不再工作了,给我错误

"xxx is not supported by the language".

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

在那行代码中,错误显示在类型为“System.TimeZoneInfo”的“.TimeZoneInfo”和“.Info”上.

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; }
}

不太确定这里发生了什么。请在这方面需要帮助。

最佳答案

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

关于迁移到 .Net4 后出现 C# 错误 "Is not supported by the language",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5575076/

相关文章:

c# - SortedDictionary 将一个 SortedDictionary 添加到另一个

.net - 如何使用 CruiseControl 从 SVN 获取特定版本的代码?

c++ - 从 C++ Visual 2006 迁移到 V2010 CFile 到 ifstream

c# - EF Core 3.1 - 如何使用 InMemory Provider 检测客户端评估错误?

.net - 如何创建 bool 编辑器模板? (.EditorFor<>)

ruby-on-rails - 在编辑器中自动打开 Rails 生成迁移文件

java - 现有数据库上的飞路迁移导致 "wrong column type encountered in column"

c# - 是否可以在共享托管服务器中使用 `ffmpeg.exe`?

c# - 避免 aspnet_compiler 运行 PreApplicationStart 方法

c# - 使用 MVC Core 时将参数传递给 main 方法