Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
Timberbird 8-Jul-11 2:19am    
Do you have Fusion log with binding information?
KiranKumar0407 8-Jul-11 2:21am    
No i don't have and i dnt know about fusion log.Could you please help me...

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.
 
Share this answer
 
Comments
KiranKumar0407 8-Jul-11 3:23am    
Hi,
It is trying to cal a method in a class which is in the dll(vs2005).But it raising an exception"System.Filenotfoundexception"
Christian Graus 8-Jul-11 3:54am    
Yes, I see that. So, step in to the code, or catch the exception, to try to work out what file it is.
Well one thing you can do is to load the assembly from a particular location and then call:
C#
Assembly a = Assembly.LoadFile(@"C:\AClassLibrary\bin\Debug\AClassLibrary.dll");


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:

C#
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.
 
Share this answer
 
v2
Comments
KiranKumar0407 8-Jul-11 3:56am    
Hi,
I tried this thing also,but it does not work.Please let me know any alternative solution for this.
Thanks for ur help.
Tarun.K.S 8-Jul-11 4:10am    
Then I would suggest you go Christian's way. You will have to "look" inside your dll to find what file do you really want.
Tarun.K.S 8-Jul-11 4:18am    
I have updated the answer. Check now.
Christian Graus 8-Jul-11 3:59am    
Why are you asking for more help, but you've not done what I told you, the only thing that will actually work ? You need to know what file you're trying to load. You can use a Reflektor or similar to read the source code of your dll, and use the exception that is thrown to look at the stack trace and see which method blows up. Nothing else will solve it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900