5

When adding a reference to VS 2008, the version is listed as v1.0.0.0 when it should be v1.1.0.0 - as far as I can see there is absolutely no reason why it is adding the wrong version.

Both projects are written from scratch, no other refs reference the assembly I'm trying to add and when I look at the file in windows, it has the correct version, yet somehow VS still picks up the wrong one (the target path is correct).

Does anyone know how to get VS to choose the version that I'm pointing it to, and not some older version it decides (for no reason at all) is the correct one?

I asked this question before, but there were no answers that solved the problem...

I AM DEFINITELY PICKING THE CORRECT FILE.

Community
  • 1
  • 1
Mr Shoubs
  • 14,629
  • 17
  • 68
  • 107
  • In add ref dialog - under recent tab, it even shows the correct version, but when you click it, the old version still comes through. – Mr Shoubs Oct 04 '10 at 15:05
  • This could be an issue with the ref'ed project as I created a new solution, added it and still had the problem... – Mr Shoubs Oct 04 '10 at 15:08
  • could you go into proj files in notepad and add the ItemGroup for the references to the question? – Iain Oct 04 '10 at 15:15

3 Answers3

4

I was having the same issue and discovered that I had a reference path set (from the Reference Paths button on the References tab of the Project properties). This meant that as I added the assemblies, it was trying to find them in the reference path first, rather than the directory I selected them from.

I removed the reference path and was able to add the files correctly.

X-Cubed
  • 1,869
  • 15
  • 24
  • Same for me, with the "old" version of the assembly having been previously installed in the GAC. When adding the "new" assembly through **Browse...**, it would instead add the reference with the strong name found in the GAC (though still with the "hint" to the browsed assembly). – Medinoc Oct 16 '17 at 13:50
1

I solved this issue by going into the project I'm trying to reference, REMOVING ALL references (e.g. system, system.core, system.data etc) and adding them all back in. This solved the problem.

I can't explain why this is the solution, especially as this project didn't have any other references in other than what you get by default.

Mr Shoubs
  • 14,629
  • 17
  • 68
  • 107
  • I have the same thing happening to me. Unfortunately, I wish I could say that it fixed my problem. – khr055 Aug 22 '11 at 19:32
  • If you have more than one project in the solution, I think you need to do this in dependency order, so the project at the top (that loads last) needs the references sorting out first, or maybe it is the other way around. – Mr Shoubs Aug 22 '11 at 20:59
0

In my case the problem was caused by some ItemGroup tags within the project file which I used to add the external assemblies to the project (to make sure version control considers them). Depending on the order of the item groups, the correct version of the external assembly has been added as reference or not.

E.g. Trying to reference the external assembly Foo.dll at the version 1.1.0.0, VisualStudio referenced the version 1.0.0.0, because Foo.dll has been present in the item group <None Include="External Assemblies\Bar\Foo.dll" /> being higher in the item group list than <None Include="External Assemblies\Foo\Foo.dll" />.

By reordering the item groups I was able to reference the desired version.

royalTS
  • 603
  • 4
  • 22