4

I have a Visual Studio 2010 project and I have referenced an assembly Oracle.DataAccess.dll which points to a local version.

I've explicitly set the option "Specific Version" to false but when the application is built I've checked the application assembly and it has a specific reference to the

Oracle.DataAccess, Version=2.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342

How not referencing a specific version of an assembly?

I'd like to rely on which version version is available in the bin folder.

It currently apparently depends on where the application is built. If I build the project on a machine that has a different version of the Oracle Client installed, then a different Oracle.DataAccess versioning reference will be in the main application.

It shouldn't rely on where the application is built really. It should not reference any specific version.

The Light
  • 26,341
  • 62
  • 176
  • 258

4 Answers4

6

Specific Version is a compile time check that the version you actually build against is the version that you actually have in the project/file reference.

Which ever version you compiled against goes into the compiled assembly metadata as a referenced assembly. This includes the assembly version number because it is part of the assembly's identity to the CLR. There is no way to have a reference to another assembly without a version being included in the output assembly.

For your scenario, I would probably set Specific Version to true so if I build it on a machine with a different version installed, compilation fails. Then I would update the project file if I wanted to compile against a new version.

If you want to run against a possibly newer version of the referenced assembly, that is properly controlled via policy. Either a publisher policy file, which Oracle would provide, or if you determine that your application is fully compatible with newer versions, via app config assembly binding redirection. This documentation provides an example of redirection via config file.

Mike Zboray
  • 39,828
  • 3
  • 90
  • 122
0

Well since you are refering to that .dll in the project, you cannot avoid specifying a version. If you want to call the .dll file without relying on its version you'll have to do it in your code. See this

Community
  • 1
  • 1
Mario Stoilov
  • 3,411
  • 5
  • 31
  • 51
  • The option is there on the dll reference and says you can set "Specific Version" to false so is this a Visual Studio bug? – The Light Dec 12 '13 at 08:10
0

If you set SpecificVersion to false, you can then easily replace the referenced assembly, it will work without any problems. The version you mentioned only indicates the version the project was build with.

You can easily check this behavior. Create a Class library project with one class in it that contains one public method that returns some string message. Build it and place resulting assembly in some folder from where you will reference it. Then create a console project that will reference your assembly with SpecificVersion=false and CopyLocal=true and outputh the message to console. Build it and run. After that, change the returned string in first project, change version, build and replace the assembly near your console project executable. Run again, you'll see that message is changed.

const314
  • 1,620
  • 11
  • 16
0

For Oracle.DataAccess the situation is a bit special. See screenshot for my installed Oracle.DataAccess

You may install verison 1.x, 2.0 or 4.0, see available downloads here: Oracle Data Access Components (ODAC) for Windows

It also depends which Oracle Client version you have installed. ODP.NET Version 1.x is available only till Oracle 11.1. Version 1.x and 2.0 are not 100% compatible to each other (but it is possbile to managed them in the same code). In VS you specify the version, e.g. 2.0. In this case you must have a version 2.x.x.x installed on your machine, in my case it will load 2.102.2.20, see policy in earlier answer. If you specify version 1.x then version 1.x.x.x must be installed on your machine. For version 4.0 I did not test yet.

In application which I develop, I provide two different Setup.exe. The customer has to select the correct setup based on his Oracle Client installation.

Furter information you can find here: ODP.NET FAQ

My installed Oracle.DataAccess enter image description here

Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110