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:
- Rebuild.
- Confirm project dependency in solution options.
- Delete reference and re-add.
- Confirm class accessibility (despite namespace not being found).
- Checked build mode (Debug/Release).
- Restart Visual Studio.
- Cleared
bin
folders in both projects. - Restart machine.
What is the next开发者_Go百科 step to diagnosing this baffling issue?
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.
Last time I had this problem my class was not marked public. Just an idea.
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.
精彩评论