Use of specific version reference in Visual Studio

2020-03-08 08:29发布

问题:

I have an assembly, Foo, which has a reference to assembly Bar (version X.X.X.2000). In the properties, the specific version is set to False. I have both Bar (x.x.x.2000) and Bar (x.x.x.1000) in my local GAC. Everything is fine.

On another machine, where no version of Bar is in the GAC, but Bar (x.x.x.1000) is located in the same directory as Foo, running Foo will fail claiming it can not find Barr (x.x.x.2000) with

Could not load file or assembly 'Bar, Version=x.x.x.2000, Culture=neutral, PublicKeyToken=YXYXYXYXXYX' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Shouldn't Foo use Bar (x.x.x.1000) since the specific version is set to False or am I missing something?

Maybe I didn't get how specific version really works.

There are some other questions about specific version references on Stack Overflow but none of it was any help to me.

EDIT

further reading: http://www.code-magazine.com/article.aspx?quickid=0507041&page=3

回答1:

"Specific Version" is a build-time property directing the compiler to use the available version. At run-time, the framework still looks for the specific version of the assembly that was used at build time.

See this forum discussion: http://forums.asp.net/t/1251728.aspx