加载在vs2005中创建的dll到vs2008中的问题

加载在vs2005中创建的dll到vs2008中的问题

本文介绍了加载在vs2005中创建的dll到vs2008中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想使用在vs2005中创建的dll到当前的vs2008项目中.我成功将dll(vs2005)添加到vs2008项目中.加载版本= 1.0.0.0``system.filenotfoundexception''''.
我尝试了以下方法......
1)我在vs2008 prjt中添加了vs2005 prjt.
2)我将dll添加到vs2008项目中.
3)我厌倦了反射概念来动态加载dll.

但是对我没有任何帮助.请帮助我.

提前谢谢.

谢谢,
Kiran

Hi,
I want to use a dll which is created in vs2005 into my current vs2008 project.I succesfully added dll (vs2005) into vs2008 project.But when i try to access the class which is in vs2005 dll,it is throwing an exception "Assembly cannot be loaded version=1.0.0.0 ''system.filenotfoundexception''".
I tried the following things....
1)I added vs2005 prjt to vs2008 prjt.
2)I added the dll to vs2008 project.
3)i tired reflection concept to load the dll dynamically.

But none of things worked for me.Please help me..

Thanks in advance.

Thanks,
Kiran

推荐答案


Assembly a = Assembly.LoadFile(@"C:\AClassLibrary\bin\Debug\AClassLibrary.dll");



我已经在此处说明了从动态加载的程序集中调用方法的方法: http: //tarundotnet.wordpress.com/2011/06/30/how-to-dynamically-load-assemblies/ [ ^ ]

让我知道它是否无效.
祝你好运. :thumbsup:

更新2:
好的,因此您无法找到要调用的方法.好了,您就可以得到所有这样的方法:



I have explained the way to invoke methods from a dynamically loaded assembly here : http://tarundotnet.wordpress.com/2011/06/30/how-to-dynamically-load-assemblies/[^]

Do let me know if it doesn''t work.
Good luck. :thumbsup:

Update 2:
Ok, so you are not able to find the method to invoke. Well then you can get all the methods like this:

Assembly a = Assembly.LoadFile(@"C:\AClassLibrary\bin\Debug\AClassLibrary.dll");
// Get the Type of the class.
Type clsType = a.GetType("AClassLibrary.AClass");
// Get all the methods of the class.
MethodInfo[] methods = clsType.GetMethods();



那么现在您将获得一系列方法.在该数组中搜索您要查找的确切方法是什么.
希望这会有所帮助.



So what now you will get an array of methods. Search in that array what is the exact method that you are looking for.
Hope this helps.


这篇关于加载在vs2005中创建的dll到vs2008中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 01:13