Click here to Skip to main content
15,867,870 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hey Guys,

i want to write a simple Application that show the depedencys from a (Managed)C# DLL or Application.

Currently i'm trying this in C# but a solution in (unmanaged)VC++ is preffered.
In C# i'm doing this with:
C#
Assembly MyAssembly = Assembly.LoadFrom( sPathToMyAssembly );
AssemblyName[] MyAssemblyNames = MyAssembly.GetReferencedAssemblies();
StringBuilder sResult = new StringBuilder();
foreach( AssemblyName MyAssemblyName in MyAssemblyNames )
{
    sResult.Append( MyAssemblyName.Name + "|" );
}
if( sResult.Length > 1 )
    sResult.Remove( sResult.Length - 1, 1 );

So i get a string with all referenced assemblys.

The problem with this solutino is, that i'm not getting a path or a full name.
I'm only get
System.Windows.Forms|mscorlib|System|System.Data|System.Drawing

as result.

I want to get something like C:\Path\To\This\Assembly.DLL
or C:\Path\To\This\Other\Assembly.EXE

Thanks so much for your help!!!!
Posted
Comments
Sergey Alexandrovich Kryukov 10-Mar-14 2:57am    
What's wrong with reading standard MSDN documentation? :-)
—SA

1 solution

I don't understand how could you miss this property: http://msdn.microsoft.com/en-us/library/system.reflection.assembly.location%28v=vs.110%29.aspx[^].

However, you should understand that this location is useful for assemblies which are not put in GAC. With assemblies in GAC, you will get correct locations anyway, only loading them from these locations won't be correct (unless this is just for research). Such assemblies are really identified by their strong names and should be referenced as such.

See also:
http://en.wikipedia.org/wiki/Global_Assembly_Cache[^],
http://en.wikipedia.org/wiki/Strong_key[^].

—SA
 
Share this answer
 
Comments
C3D1 10-Mar-14 3:23am    
thanks for your help!
I don't know how i could miss this property...
*Facesmash*
Sergey Alexandrovich Kryukov 10-Mar-14 9:55am    
You are very welcome.
I wrote this "I don't understand how could you miss..." because, from your question, it looks like you really understand the whole topic.

Good luck, call again.

—SA
C3D1 10-Mar-14 11:55am    
yea, i have no idea how this could happen...
Maybe at the time i read the MSDN documentation about the assembly class it was early in the morning and the first coffee was still in progress at the machine and then i accidently skipped this property...

Really sorry for wasting your time!
Sergey Alexandrovich Kryukov 10-Mar-14 14:59pm    
No, no! It doesn't matter at all. It's a pleasure to help someone who can understand the matter and can actually make things working. Too many inquirers here just fool around or even fail to behave adequately. Some not even try to read documentation...
I would like to say thank you for correct accurate formulation of your question, adequate response to answer and so forth...
—SA

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