FileLoadException与新版本的dll [英] FileLoadException with new version of dll

查看:216
本文介绍了FileLoadException与新版本的dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序需要使用两个版本的dll。我想我只是编译该应用程序一次,将exe复制到两个目录,然后将这两个版本的dll复制到这些目录中。我没有与GAC做任何事情。但是,我收到一个FileLoadException的版本与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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆