0
I have a project where I need to use a reference with different versions in a single execution, example:
Switch System.Drawing version 2.0.0 to System.Drawing version 1.0.0
It’s possible to do that?
0
I have a project where I need to use a reference with different versions in a single execution, example:
Switch System.Drawing version 2.0.0 to System.Drawing version 1.0.0
It’s possible to do that?
0
It is possible through a dynamic Assembly invocation:
// caminho da DLL antiga
var assembly = Assembly.LoadFile("caminho");
// tipo da classe desejada
dynamic instancia = assembly.CreateInstance("tipo");
// chamar o método que está procurando ou fazer o que precisar com a variável
instancia.MetodoDesejado();
Browser other questions tagged c# reference
You are not signed in. Login or sign up in order to post.
Why is that necessary? Describe your problem better, as there may be other ways to solve it that may have nothing to do with the
System.Drawing
– Leandro Angelo
I was curious to know why you want this, for me it doesn’t make sense
– Rovann Linhalis
@Exact Rovannlinhalis... because you can even make copying, renaming and using alias... But I can’t see any sense in it.
– Leandro Angelo
@Leandroangelo I don’t think so... but I’ll wait for the reason of the thing
– Rovann Linhalis
I’m dealing with system integration, where older versions of the system uses dll with an older version and when the program is doing calculations on newer systems, it needs to change the reference of this old dll to a newer version. Basically I can’t use this recent dll on an old system, so I have to change it. And I need to do this on the same run. Because I will make calculations on different version systems with the same dll (with different versions).
– Forsaiken
It is possible to load a dll dynamically, but cannot be referenced. If you have already added this reference to your project, it cannot be changed and the program will use this reference. In your case you will not be able to reference this dll and then load the ones you need dynamically using
Assembly.Load(path)
. Then you can use dll methods using Reflection.– Guilherme Batista