2

I'm trying to access System.Collections.Generic.Stack<> in Visual C# 2010 Express, but the IDE (and compiler) claim that it's not present. Several other classes are also missing, including LinkedList<>, SortedList<> and Queue<>. I've checked the documentation for both the System.Collections.Generic namespace and C# Express, and can find no reference to any deliberate limitations.

Oddly enough, if I sort the documented contents of the System.Collections.Generic namespace alphabetically, everything after List<> is missing, but that may just be a very weird coincidence.

Edit: I tried a commandline build using MSBuild, which also complained with error CS0246. However, using csc worked.

Followup: I tried removing all resources from my project and adding a stub class which just created an instance of Stack<>. Not only did that work, everything still worked after adding the old class back in and removing the stub. I can only assume there was some kind of caching silliness going on. Very annoying. I'll re-open if this issue reappears.

Catalept
  • 23
  • 4
  • Are you sure you have the relevant references added to your project? They should be there by default but may have been removed by mistake. mscorlib.dll is what you need – Tom Studee Jul 23 '11 at 02:43
  • @Tom - If he didn't have mscorlib, then he wouldn't have List and Stack is in [System.dll](http://msdn.microsoft.com/en-us/library/3278tedw.aspx) :-) – CodeNaked Jul 23 '11 at 02:45
  • Ah, true. Just grasping at straws here – Tom Studee Jul 23 '11 at 02:49
  • Does the compiler give you errors, or just the IDE? – Gabe Jul 23 '11 at 03:26
  • It does sound like he might be missing a reference to System.dll, since everything that's alphabetically after `List` is in System.dll (whereas `List` itself is in mscorlib.dll). – Sven Jul 23 '11 at 04:03

1 Answers1

2

I expect that your project is missing a reference to System.dll.

Check whether "System" is listed under "References" in the solution explorer. If not, right-click References, choose "Add Reference...", and add a reference to "System".

Note: List<T> is in mscorlib.dll, and all collections that are alphabetically after List<T> are in System.dll, which is why I think this is what's happening.

Sven
  • 21,903
  • 4
  • 56
  • 63