Reputation: 2504
I am running into a very strange problem and I would like to understand what is happening. I have a solution with 30 projects and all it is working fine except one of them. This project has a dependency on another project in the same solution. Adding a Project reference, looks fine in the editor (no red lines etc) but when compiling I get compiler error as if the reference is not there. However if I go and Add Reference directly on the DLL which the project generates then it works fine. I double check and in both scenarios it references the exact same DLL. Why it wouldn't work as a project reference? Any ideas welcome !
Upvotes: 1
Views: 1756
Reputation: 2504
The name of the project was different from the name of the folder was under. Not sure it had something to do with that when using it as project reference but renaming the project folder fixed the issue.
Upvotes: 0
Reputation: 289
Both projects are in the same solution? If yes, you might want to check the build order for them, make sure the referenced one is build before the one that references it. Also there is a bug in the MSBuild maybe this will solve your problem : solution to MSBuild error
Upvotes: 0
Reputation: 942257
Project build order is a ratty problem to solve and MSBuild certainly does drop the ball sometimes. There isn't anything in the question that helps us help you find the root cause.
The simple solution is to help MSBuild and just be explicit about it. Right-click the project that doesn't build correctly and select "Project Dependencies". Tick the ones that need to built first. Also note the Build Order tab in that same dialog, it shows you in what order the projects are going to get built. Make sure it is now a happy order.
Also note that it is technically possible to create a circular dependency. It isn't simple to do, it requires incrementally changing the projects and adding references to existing DLLs. In other words, what you did and shouldn't have done :) You diagnose that with Build + Clean and never succeeding in building the solution again.
Upvotes: 3
Reputation: 13106
I'll recommend editing the project file and taking a look at what each reference is actually pointing at. Also, check the configuration manager and make sure that the 'problem' project is being included when being build for the particular platform \ configuration you are building against. '
Upvotes: 0
Reputation: 4636
When I've run into issues like this I've generally fixed them by one of two things...
Upvotes: 0
Reputation: 2445
You might not be referencing the latest build of the said DLL. The direct DLL reference will not force that DLL to be rebuilt, but a project reference will. Sometimes VS does not report dependency DLL build errors clearly, so it could well be that there is an error in the latest code for the DLL and one you are linking to is an old one. Try looking at the output window (as opposed to the errors list) for detail on why it won't build.
Upvotes: 0