How to refrence any avalible version of a assembly?

Hi,

we have a problem in our company and we can’t solve it.
We have an application that uses the Oracle Data Provider (ODP).
But when you move the application to another computer that has a different version of ODP (newer version) installed the application doesn’t work, because it is trying to reference a assembly with a specific version and that does not exists...
I was going trough the MSDN and some books, and discover that you can manually redirect assembly with:

<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="AssemblyName" publicKeyToken="XYZ" culture=""/>
<bindingRedirect oldVersion= "1.0.0.0" newVersion= "2.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

this is OK, but the problem is that we can't know which version of ODP will be on the target computer and we can't manually configure every computer.

We have two ideas (with first being a hack). One is to manually write the version of ODP that is installed on the computer to the config file during the installation.
The other is to dynamically load the available assembly during runtime.

But we would like to solve this in a more elegant way if it is possible.

I have searched these forums but didn’t found any solutions.
I would very much appreciate some useful information’s.




Answer this question

How to refrence any avalible version of a assembly?

  • Crax123

    Yes that is what I have discovered...
    I was looking for a better way, but it seems there isn't one...

    Tnx for all your replys.


  • venkatesh

    Maybe im a bit late with this post, but i just found this thread and have an idea.

    What about using late binding
    The location of Oracle.DataAccess.dll can be found using ORACLE_HOME i think, or maybe via registry.
    With the location we can use
    Assembly myAssembly = Assembly.LoadFrom(dllfile);
    myObject = myAssembly.CreateInstance("Oracle.DataAccess.Client.OracleConnection", true);

    As far as you're only using basic functionality, there should be no problem. Otherwise, myAssembly.GetName().Version should be checked for compatibility.

    During development, early binding can be used to have code completition & stuff.

    I havent used the above code but it should work this way.

    ciao
    alberich



  • Gu&amp;#38;&amp;#35;240&amp;#59;mundur

    CLR binding model intentionally does not provide a way to reference "any version" of an assembly.

    For all your dependencies, you should package them with your application, or with a config file to redirect to different version.

    You can generate the config dynamically during setup time if you don't know which version the client has. The config file is just plain xml file.



  • amaly0827

    The problem is that the client does not wish to install another version.
    And we are searching for a solution that will work with other assemblys too.
    Becouse we can't ship 50 products with our program just so we are shure everything works....


  • Skafever

    Can't you just include the version you've compiled against in your setup package and install it as a local asembly in the application directory (i.e. not put it in the GAC)

  • How to refrence any avalible version of a assembly?