How exactly are Projects in the same Solution related?
I assumed when I have, say Project A and Project B, and Project B depends on Project A, I would be able to use in Project B the classes defined in Project A. So if I have
namespace HiFolks
{
public class SomeClass{}
}
in Project A, then I can use HiFlolks.SomeClass
in Project B just as if it were defined in Project B. It worked like this before but now I just added a project called Storm to my solution and set it my project, say 开发者_JAVA百科Project X, to depend on Storm, but I get this error: "The type or namespace name 'Storm' could not be found (are you missing a using directive or an assembly reference?)". This happens even after building and rebuilding the solution successfully.
I might be missing something related to how projects work, I really never knew it other than by experience. Haven't found any documentation about it since whenever I search for anything in the VS help page I get a bunch of blogs and random people opinions as results instead of an official documentation. Please, any help will help.
How did you "set Project X to depend on Storm"? I wonder whether you've gone into the build settings for the solution to make sure that Storm builds before Project X, but without a reference between them.
Basically you need to add a reference from Project X to Storm, e.g. by right-clicking on "References" in Project X in Solution Explorer, and then choosing "Add Reference". Select the Projects tab, and select Storm. If you can tell us which version of Visual Studio you're using, we will be able to provide more detailed help and perhaps screenshots.
Note that adding a reference doesn't mean you can use all types or members as if they were defined in the same project - if there are internal members within the referenced assembly, you won't see those from the project which has the reference1.
Of course, the other alternative is that you're simply trying to use a class without the appropriate using directive to import the relevant namespace. If you could provide a sample solution demonstrating the problem as a zip file, we could tell exactly what's wrong fairly easily, I suspect.
1 Yes, there's [InternalsVisibleTo]
but let's keep things simple for now.
Have you added project reference?
精彩评论