I just upgraded last week from Visual Studio 2005 to 2008. I am having an issue with compiler resolving namespaces when I use a class as a type in a Generic collection. Intellisense recognizes the class and the compiler generates no errors when I use the class except when it is a type in a Generic collection declaration either as return type for a Property or as a parameter to a method. This is happening in my only project that is targeting the 3.5 framework, but changing the project containing the class to use the 3.5 framework doesn't fix the problem.
Examples
Compile fine
MyClass myClass = new MyClass();
SortedList <DateTime,MyClass> listOfClasses = new SortedList<DateTime,MyClass>
Compile error - Namespace could not be found
public SortedList<DateTime,MyClass> ClassList
{
get;
set;
}
private void DoSomethingToLists(SortedList<DateTime,MyClass> classList)
Intellisense has no problem resolving the namespace, only the compiler.
Is this a known bug or am I missing something obvious? Will SP1 fix it?
I was able to create a new library containing just this class targeting 3.5 and am now able to successfully use this in both 3.5 and 2.0 projects. My guess is that even though I tried to change the target of my original library, since it was still referencing 2.0 projects there was some conflict.