0

I have an issue with a class being used in another project.

Visual studio is able to add a using statement using Resolve (Ctrl+.), but:

The type or namespace name 'SomeClass' could not be found (are you missing a using directive or an assembly reference?

Resolving this again fully qualifies the type but the namespace in the type path is highlighted as not being found.

The namespace appears also in intellisense and the target class is visible in the Object Browser.

Removing unused namespaces removes the added using statement.

I've tried:

  1. Rebuild.
  2. Confirm project dependency in solution options.
  3. Delete reference and re-add.
  4. Confirm class accessibility (despite namespace not being found).
  5. Checked build mode (Debug/Release).
  6. Restart Visual Studio.
  7. Cleared bin folders in both projects.
  8. Restart machine.

What is the next step to diagnosing this baffling issue?

StuperUser
  • 10,555
  • 13
  • 78
  • 137

3 Answers3

1

This is likely to be a .Net framework versioning issue. The class being referenced was probably built using a higher version of the framework.

Try checking your framework versions all align in properties, build settings. A project cannot reference an assembly of a higher framework version.

TheCodeKing
  • 19,064
  • 3
  • 47
  • 70
  • Nope, they are both the same version. Is there more granularity other than that Target Framework dropdown containing {2.0, 3.0, 3.5, 4.0}? – StuperUser Sep 19 '11 at 18:02
  • There's whether it's client profile or not, other than that no. What you are experiencing is usually this issue. Is the dll copied to the bin? – TheCodeKing Sep 19 '11 at 18:09
  • It's not, and I've gone through: http://msdn.microsoft.com/en-us/library/cc668079.aspx with no joy. – StuperUser Sep 19 '11 at 18:29
0

Last time I had this problem my class was not marked public. Just an idea.

Decker97
  • 1,643
  • 10
  • 11
  • Thanks Decker, the namespace is what's not found and I don't think you can modify the accessibility of a namespace. Checking the class(es) was number 4 on my list. – StuperUser Sep 19 '11 at 18:30
  • What happens if you put in the namespace.class.function directly? sometimes it will give rollover help for why it's not found. – Decker97 Sep 19 '11 at 18:35
  • Resolving this again fully qualifies the type but the namespace in the type path is highlighted as not being found. – StuperUser Sep 19 '11 at 18:38
0

This issue was caused by similar namespaces e.g. Company.Product.Project and Product.Project with:

namespace Company.Product.Project
{
        using Product.Project;

The class was in Product.Project, but the compiler was searching for Company.Product.Project.

See: Should 'using' statements be inside or outside the namespace? for more details.

Community
  • 1
  • 1
StuperUser
  • 10,555
  • 13
  • 78
  • 137