Batiatto
Batiatto

Reputation: 59

Multiple versions of same referenced assembly

I have an issue and couldn't resolve it so far.

I have an assembly (an executable .net 4.0) that loads plugins (.dll assemblies) from a folder. the main executable has a reference to telerik.windows.controls.dll and runs all well.

now i write a new plugin that uses a newer version of the telerik library, and to be more concrete the assembly telerik.windows.controls.GanttView. The problem is that the GanttView control uses a newer version of the telerik.windows.controls.dll and therefore i got a crash as the plugin can't load the telerik referenced assemblies.

i know i could resolve this by upgrading all to the latest set of referenced assemblies (telerik), but those controls haven't been QA'd / tested by my team to ensure that no new bugs are introduced.

So, to summarize it:

main.exe -> a.dll -> X.dll (v1)

then I add a new plugin called b.dll so:

main.exe ->b.dll-> X.dll (v2) +------------> X.dll (v1)

so the question is whather my plguin can reference a different version of an assembly (and that one its referenced assemblies too) from a different location as now it loads up the ones loaded by the main assembly.

thanks.

Upvotes: 3

Views: 841

Answers (2)

Kevin DiTraglia
Kevin DiTraglia

Reputation: 26078

We accomplished this at some point in our app. The way we did it was create a folder within the bin directory that held the out of date dll, then added the following lines to the app.config files that were referencing the old dll...

<runtime>
    <assemblyBinding xmlns = "urn:schema-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity 
                name = "YourAssembly"
                />
            <codeBase version="YourAssemblyVersion" href = "FolderWithinBinDirectory/YourAssembly.dll"/>
        </dependentAssembly>
    </assemblyBinding>
</runtime>

There might have been more to it, but I think that's all we had to do.

Upvotes: 1

Maarten
Maarten

Reputation: 22955

The short answer is no, if the newer dll has the same assembly-info.

The longer answer is, that in an Application Domain (which you wouldn't have more of than one unless you create more yourself), you can load a specific assembly only once. Once again, this is assuming the assembly (dll) we're talking about has the same assembly info. If you want to load the newer assembly, you'll have to create a separate application domain. But then you won't be able to use it in the initial application domain, where your other controls are ' living'.

Upvotes: 1

Related Questions