Finding Info about a dll using Reflection
-
Hi, For pulling information about a dll, I have tried Assembly.Load("dll name"), it doesn't work and I understand that I need to pass a full name. My requirement doesn't provide the full name, only the name of the dll should be passed and I should get full name with version, culture inforamtion etc. Can some one tell how to fetch the version, culture etc information when given a dll name which is there in GAC.. Thanks for your help. Satya :-D
-
Hi, For pulling information about a dll, I have tried Assembly.Load("dll name"), it doesn't work and I understand that I need to pass a full name. My requirement doesn't provide the full name, only the name of the dll should be passed and I should get full name with version, culture inforamtion etc. Can some one tell how to fetch the version, culture etc information when given a dll name which is there in GAC.. Thanks for your help. Satya :-D
SatyaDY wrote:
it doesn't work
What happens? Does it throw an exception? Does it silently do nothing? Crash your hard disk? I think the method you want is Assembly.LoadFile().
Cheers, Vıkram.
Déjà moo - The feeling that you've seen this bull before. Join the CP group at NationStates. Password:
byalmightybob
-
SatyaDY wrote:
it doesn't work
What happens? Does it throw an exception? Does it silently do nothing? Crash your hard disk? I think the method you want is Assembly.LoadFile().
Cheers, Vıkram.
Déjà moo - The feeling that you've seen this bull before. Join the CP group at NationStates. Password:
byalmightybob
Yes it throws exception.. Assembly LoadedAssembly = Assembly.LoadFile(@"c:\WINDOWS\assembly\mscorlib.dll"); Exception Occured: The system cannot find the file specified. (Exception from HR ESULT: 0x80070002) I tried both Load and LoadFile, getting the similar exception. Any clues? Thanks Satya
-
Yes it throws exception.. Assembly LoadedAssembly = Assembly.LoadFile(@"c:\WINDOWS\assembly\mscorlib.dll"); Exception Occured: The system cannot find the file specified. (Exception from HR ESULT: 0x80070002) I tried both Load and LoadFile, getting the similar exception. Any clues? Thanks Satya
The issue that you have here is that there is no file "c:\WINDOWS\assembly\mscorlib.dll". If you go to the command line and type in dir c:\windows\assembly you will see that it lists directories. The version that you see in the Windows shell is a wrapper to make it convenient for managing GAC entries.
Deja View - the feeling that you've seen this post before.
-
The issue that you have here is that there is no file "c:\WINDOWS\assembly\mscorlib.dll". If you go to the command line and type in dir c:\windows\assembly you will see that it lists directories. The version that you see in the Windows shell is a wrapper to make it convenient for managing GAC entries.
Deja View - the feeling that you've seen this post before.
-
Yes it throws exception.. Assembly LoadedAssembly = Assembly.LoadFile(@"c:\WINDOWS\assembly\mscorlib.dll"); Exception Occured: The system cannot find the file specified. (Exception from HR ESULT: 0x80070002) I tried both Load and LoadFile, getting the similar exception. Any clues? Thanks Satya
In addition to what Pete said... why do you want to load that particular DLL? If you want to look at the contents of mscorlib.dll, I suggest you fire up wincv.exe. If you want to load any DLL, verify the path and use Assembly.LoadFile(). I think relative paths will work with Assembly.LoadFile(), but if it blows up, Path.GetFullPath() is your friend.
Cheers, Vıkram.
Déjà moo - The feeling that you've seen this bull before. Join the CP group at NationStates. Password:
byalmightybob
-
Yes, you are correct. Not aware of this point... But how to find out the info about the dll which are in GAC, (only know the dll name)? I am really struck here, Thanks for your help. Satya
If you only know the DLL name, then you should use
Assembly.Load();
Here's an example:Assembly assem = Assembly.Load("mscorlib.dll");
Deja View - the feeling that you've seen this post before.
-
If you only know the DLL name, then you should use
Assembly.Load();
Here's an example:Assembly assem = Assembly.Load("mscorlib.dll");
Deja View - the feeling that you've seen this post before.
-
It works only with mscorlib.dll, if you try with some other dlls it fails... I am trying to build an application which needs the full deatils of the dll and it uses this information to generate a binding file.
Well, the hack way to do this would be:
Assembly assem = Assembly.Load("mscorlib.dll"); if (assem != null) { string path = System.IO.Path.GetDirectoryName(assem.Location); assem = Assembly.LoadFrom(System.IO.Path.Combine(path, "System.Xml.dll")); }
Deja View - the feeling that you've seen this post before.
-
Hi, For pulling information about a dll, I have tried Assembly.Load("dll name"), it doesn't work and I understand that I need to pass a full name. My requirement doesn't provide the full name, only the name of the dll should be passed and I should get full name with version, culture inforamtion etc. Can some one tell how to fetch the version, culture etc information when given a dll name which is there in GAC.. Thanks for your help. Satya :-D