加载在vs2005中创建的dll到vs2008中的问题 [英] problem in loading dll which is created in vs2005 into vs2008

查看:99
本文介绍了加载在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

推荐答案

世上没有理由让您遇到此问题.我建议您进入您的dll,找出正在尝试访问文件的行.更好的是,如果捕获到此异常并查看堆栈跟踪,则可以在那里找到它发生的位置,甚至找到它要查找的文件.它正在尝试加载文件,但它不能.我怀疑这与.NET版本有关.
There is no reason on earth for you to have this issue. I suggest you step in to your dll and find out what line is trying to access a file. Better yet, if you catch this exception and view the stack trace, you can find out where it happened, and perhaps even what file it is looking for, there. It''s trying to load a file and it can''t, I doubt that has to do with the version of .NET.


您可以做的一件事就是加载从特定位置组装,然后调用:
Well one thing you can do is to load the assembly from a particular location and then call:
Assembly a = Assembly.LoadFile(@"C:\AClassLibrary\bin\Debug\AClassLibrary.dll");



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



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中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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