Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Error "Is not supported by the language" after migration to .Net4

Tags:

c#

.net

migration

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

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

"xxx is not supported by the language".

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

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

Definition of user.Settings.TimeZoneInfo property is:

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

Definition of l.TimeZoneItem.Info property is:

public TimeZoneInfo Info
{
    get { return info; }
}

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

like image 942
Lancelot Avatar asked Apr 07 '11 01:04

Lancelot


2 Answers

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.

like image 153
Jonathan Perry Avatar answered Oct 17 '22 15:10

Jonathan Perry


This also happens when a lower library is using a different versionof the .NET Framework. Had a similar issue and when I updated the Lower Libraries to 3.5 framework and the actual library to the 3.5 framework the problem went away.

like image 5
Patrick Avatar answered Oct 17 '22 15:10

Patrick