Friday, 16 August 2013

"Type or namespace name *name* cannot be found" Error only in method declarations

"Type or namespace name *name* cannot be found" Error only in method
declarations

I am getting a "Type or namespace name name cannot be found" error, but
only in the method declarations, and only on two specific object types:
public List<Transit> GetStops() //This throws error
{
List<Transit> stops = new List<Transit>(); //This does not throw error
If I try to access Transit through the Path.To.Namespace.Transit in the
method declaration, I still get the error. Visual Studio 2012 can find the
class in the auto suggestions both in the method declaration, and below it
(Before I try to build again). Something like the code below will throw no
errors:
public List<string> GetStops()
{
List<Transit> stops = new List<Transit>(); //No Error
This occurs for only 2 classes located in that namespace.
public Stop GetCurrentStop() //Error
{
Stop stop = new Stop(); // No Error
The rest of the classes in that namespace will not throw this error. Both
classes are public and only contain a constructor. Visual Studio will list
both objects as suggestions, and will map them to the correct namespace in
the code below the method declaration.

No comments:

Post a Comment