Click to See Complete Forum and Search --> : Getting Assembly Version?


mase
May 15th, 2009, 01:32 PM
Hello everyone,

I have been trying to get the assembly version of the third party DLL that I use in my program, but I'm unable to retrieve it and I can not seem to know why. When I create my own DLL just for testing, it works, but when apply the same method to retrieve third party DLL, it doesn't work.

This works when I try to get the version of my own test DLL:

string assemblyPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.LoadFrom(@"\Windows\TestLogFile.dll").GetName().CodeBase);
listBox1.Items.Add(assemblyPath);
System.Version objVersion1 = System.Reflection.Assembly.LoadFrom(assemblyPath + @"\TestLogFile.dll").GetName().Version;
testMsg.Text = objVersion1.ToString();


But when I try the same approach just to get the path to the third party DLL, but can't get it:

string assemblyPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.LoadFrom(@"\Windows\DMRK.dll").GetName().CodeBase);
listBox1.Items.Add(assemblyPath);


Error: File or assembly name "\Windows\DMRK.dll"; or one of its dependencies, was not found.

Does anybody know why?

thanks,

boudino
May 18th, 2009, 02:52 AM
1. Does the file exists on the given location? (e.g. the working dir is d:, but the windows folder is located on c:)
2. It is a .NET assembly, or common .dll?

mase
May 18th, 2009, 12:29 PM
Yep, the file exists in the Window directory. The third party API that I use, they have two assembly files. To use their API, I have to include the .NET assembly to my project and another DLL is installed automatically into Windows directory when I install their CAB file. I'm able to get the version of the .Net assembly file, but when trying to get the DLL in Windows directory, it gives me error message like in my first post.

I don't understand your second question what is .NET assembly and common DLL. I guess maybe the DLL in Windows directory is common dll.

if you can help, very appreciated.

thanks.

boudino
May 19th, 2009, 09:32 AM
Try look at this (http://www.codeguru.com/cpp/w-p/dll/article.php/c113).

mase
May 19th, 2009, 04:33 PM
boudino, thanks for the link. It has good information on it. From the example, can it be used in smart device runs on WinCe?

boudino
May 21st, 2009, 02:15 AM
I suppose it could be, probably with some modifications, but I don't know it.