FileLoadException与新版本的dll [英] FileLoadException with new version of dll
问题描述
在项目中,我的具体版本设置为false为dll参考。但是,也许这是错误的设置。我如何得到这个工作与多个版本?
我决定改变配置文件,只是因为它是另一件事将需要做。关于dll的不同版本的地址更改,我不认为我有这个问题,因为我实际上正在使用一个界面来调用我的方法。
再多一些细节,我只需要在多个DLL中创建一个类型的实例。从那里,我将其视为一个接口对象。所以,这是我的解决方案:
程序集asm = Assembly.LoadFrom(XXX.YYY.ZZZ.Bin.dll) ;
类型type = asm.GetType(MyType);
IMyType obj = Activator.CreateInstance(type)as IMyType;
这似乎有效。
I have an application that needs to work with two versions of a dll. I figured I would just compile the app once, copy the exe to two directories, and then copy the two versions of the dlls to each of these directories. FYI, I'm not doing anything with the GAC. However, I'm getting a FileLoadException on the version with the dll it was not compiled with.
In the project, I have the "Specific Version" set to false for the dll reference. But, maybe that is the wrong setting. How do I get this to work with multiple versions?
I ruled against changing the config file, simply because it's another thing I would need to do. In regards to the address changing for different versions of the dll, I don't think I have that problem since I am actually using an interface to call my methods.
To give a little more detail, I simply need to create an instance of one type in multiple dlls. From there, I treat it as an interface object. So, here is my solution:
Assembly asm = Assembly.LoadFrom("XXX.YYY.ZZZ.Bin.dll");
Type type = asm.GetType("MyType");
IMyType obj = Activator.CreateInstance(type) as IMyType;
This seems to work.
这篇关于FileLoadException与新版本的dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!