开发者

Visual Studio 2008 having problems with namespaces when used as type in Generic coolection

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 ab开发者_JAVA百科le 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜