简体   繁体   中英

How can I get multiple versions of the same application to use the same version of an assembly? c#

I have a web application "App1" of which there are many versions all being hosted concurrently on the same server (each with their own version of an assembly "AssemblyA"). This application has the ability to upload c# files and compile and run them as required and these c# files can consume "AssemblyA".

I want to create a new assembly ("AssemblyB") that these c# files can all consume in addition to "AssemblyA". AssemblyB must reference the same version of AssemblyA as these c# files.

I have no control over when a new version of App1 is released or an existing version is updated and almost no power to change the source code in App1. I cannot simply add a new AssemblyB project to the App1 solution and deploy the whole lot together.

When AssemblyB is updated I would like to have some way of deploying it so that all c# files that are generated on-the-fly in all versions of App1 would use this new version.

Is it even possible to do this? Is there some global location into which I could deploy my AssemblyB .dll and have it consume the correct version of AssemblyA depending on the version of App1 that is hosting the c# code?(such as the GAC, or is that a really bad idea?)

I could change App1 source code to allow it to load the latest version of AssemblyB and provide it to the c# files, but if so where would I store the latest version of the .dll for it to use?

The answers provided may depend on the number of versions of App1 there are out there. So consider how this may be done in the event that there are only two versions of App1 and 10,000+ versions.

I think you should try some automatic mechanism on the total flow, from updating version to generating dll and deploying. It could be done via shell, or tools like jenkins.

In the end the solution was incredibly simple. I just needed to copy AssemblyB.dll into the bin folder of any of the versions where there were uploaded c# files that referenced it. Since AssemblyA and AssemblyB were in the same location AssemblyB just seemed to work with what ever version of AssemblyA was present. It did not require any changes to the code in App1. I should always try the simplest thing first and never assume things "can't be that simple"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM