Could not get dependencies for project reference
Asked Answered
L

14

36

I have a C# solution with a website project and a C# library. When compiling the solution, the website gives the message:

Could not get dependencies for project reference 'MyLibrary'.

This does not stop the wbsite compiling and running until I try and build it with a TFS build, when this error message fails the build.

What does this mean and how can I get round it?

Lindsy answered 14/5, 2009 at 13:35 Comment(0)
V
8

Open the Website proj file in notepad and check the reference etc... can help

Vortical answered 14/5, 2009 at 13:39 Comment(1)
Visual studio showed the reference existed with its little check mark, but I had to add a <ProjectReference> to the proj file to make it work.Tacnaarica
L
40

After trying many things, I realized something. The error was never going away, no matter what I did to clear the builds and such. I closed and reopened the solution and it went away.

Lowpitched answered 16/3, 2010 at 19:24 Comment(2)
By closing solution, you mean closing Visual Studio?Crosspiece
This worked for me. Closing visual studio and re-opening the solution solves it. The behavior comes and goes. I had a visual studio 2015 solution compressed in a zip file. I decompressed it once and it ran fine. Then I decompressed the exact same file again and this behavior showed up.Calcimine
A
15

When you get the error message "Could not get dependencies for project reference", one of the possible causes could be that you are referencing another project in your solution which has a Target framework not compatible with the target framework of the referencing project.

You can see the target framework specified for a project by going to the project properties and selecting the Application tab on the left.

I'm writing this because it happened to me, I was referencing a project with Target framework 4.0 from a project with target framework 3.5.

Agan answered 17/11, 2012 at 15:40 Comment(3)
Thanks. I had the same issue when I was referencing projects with framework 2.0 from a project with 4.6.2.Templar
Also, "Core" is not compatible with "Framework", but ".NET Standard" is compatible with everything.Garling
I am getting this error with referencing projects that target .NET Standard 2.0 from an ASP.NET Web Forms project targetting .NET Framework 4.6.1, so I'd be very careful about saying .NET Standard is compatible with everything.Plashy
V
8

Open the Website proj file in notepad and check the reference etc... can help

Vortical answered 14/5, 2009 at 13:39 Comment(1)
Visual studio showed the reference existed with its little check mark, but I had to add a <ProjectReference> to the proj file to make it work.Tacnaarica
H
5

In my case the referenced project was created on VS 2010 while the referencee was a VS 2008 solution. In this case just edited the vs 2010 project with notepad, and changed the ToolsVersion="4.0" to ToolsVersion="3.5"

Hepta answered 11/10, 2012 at 17:35 Comment(1)
You can also make this change in the Properties screen of the project.Betancourt
S
2

Look in your references. Make sure you have the correct path for the project reference for MyLibrary.

I would try to remove it and add it. Then instead of build I would choose Rebuild Solution, because rebuild deletes all .dll and rebuilds them.

Salvador answered 14/5, 2009 at 14:6 Comment(0)
O
2

If by "TFS build" you mean you are using a separate build server then you could try checking the build configuration that the build server is using.

For example, when you build on your local machine you may be targeting the debug configuration while the build server is using the release configuration.

Configuration Manager

In each build configuration you could ensure that the project "MyLibrary" is selected to build.

Obtrusive answered 22/10, 2010 at 19:51 Comment(0)
S
1

This is an official bug in the VS SDK:

https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=276380

I opend this one, and I could read the following there: Von Microsoft am09.05.2007 um 19:05 bereitgestellt

Thanks for your feedback. We have reproduced this bug on Visual Studio 2005 SP1, and we are sending this bug to the appropriate group within the VisualStudio Product Team for triage and resolution.

Thank you, Visual Studio Product Team.

I think this bug still exists for web site projects and yes; we use VS 20102 Ultimate. I have an application in \APP_CODE under my Virtual Directory and I have 2 DLL of which the source code is C#, and I have 3 DLL?s of which the source code is Oxygene, OXygene (PASCAL) from RemObjects. I see this reference only with the DLL's written in PASCAL; but when I test this 3 DLL's from a test application all is fine and my test application has absolute no problem to reference any classes or vars inside this 3 DLL's. So what could be the difference in compilation/build ledaing to the following error string in the VS output window. An erro which as described many times, never goes away.

Could not get dependencies for project reference 'Toolbox'Could not get dependencies for project reference 'IMPLEM'Could not get dependencies for project reference 'LEGACY'Validating Web Site

Starla answered 1/6, 2009 at 15:18 Comment(1)
I don't think this bug is the root cause of the problem. We're not using the Managed Package Framework, as far as I can tell.Helton
F
0

If you get this problem all the time even after cleaning and rebuilding the solution, then it means there is something wrong with any of the referenced projects. Check the Output window for any warnings during the compilation process. Remedy the warning and it could help you compile with success.

Felicity answered 1/10, 2010 at 18:55 Comment(0)
D
0

"Clean Solution" cant help, sometimes you need to remove DLL manually from website project (Bin folder). Remove DLL and build the Solution again.

Darien answered 19/11, 2016 at 15:6 Comment(0)
G
0

In my case I had dropped .NET 4.6 updated assemblies on the solution and one of the projects happened to be set to .NET 4.5, either downgrading the assemblies or upgrading the project to 4.6 fixed it.

Grantee answered 9/10, 2019 at 11:1 Comment(0)
P
0

I just removed the Website Project and added it again to the solution. However, I noted that packages.config was then created. This config file was not present previously.

Pimento answered 7/1, 2020 at 9:26 Comment(0)
I
0

Could not get dependencies for project reference 'X'

This error comes due to a lot of reasons, and the error message is showing in the VisualStudio Error Window is not precise. Thus the confusion.

General Cause: Project 'X' References: One of the Project/DLL referenced by Project X is either not working or is incompatible.

Troubleshooting Tips

  1. First Rebuild the Project X and watch our for "error" in the Output Window. Ensure all the dependencies are met and there are no errors in the build output log.
  2. In case of any Project Dependencies, ensure that the build output path matches. If not, Remove and Add correctly.
  3. Architecture mismatch in case of case of any Project Dependencies. Ensure you have similar/compatible build configuration for all the referenced projects.
  4. Try to analyze the csproj file opening in a notepad, this might help in case all the above steps are ok, and error is still the same. So it can be VisualStudio issue.
  5. All the above fail, and you have upgraded framework or changed dll references a lot then it is better to close and reopen visual studio and try again.

Hope that helps save development time.

Immotile answered 16/2, 2021 at 10:36 Comment(0)
B
0

I was facing the same issue. When I checked the output window for logs and found the following:

warning MSB3274: The primary reference "SOMEASSEMBLY, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" could not be resolved because it was built against the ".NETFramework,Version=v4.5" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.0"

So I upgraded my project to the .NET Framework 4.5 and that was built successfully.

Bronez answered 2/4, 2022 at 7:10 Comment(0)
S
-1

Try to check on the configuration for the project. I've noticed that changing it to 'any CPU' works.

Schaumberger answered 22/10, 2010 at 19:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.