R
Ron M. Newman
Hi: How do I get the GUID string out of an assembly? (I have it loaded and
referenced from an Assembly obect).
-Ron
referenced from an Assembly obect).
-Ron
Kevin Spencer said:This is an attribute in the Assembly Manifest. You get to it by getting an
instance of the System.Reflection.Assembly class, using:
System.Reflection.Assembly assembly = Assembly.GetExecutingAssembly();
Then you get an Attribute from the assembly using the
Assembly.GetCustomAttributes method:
((System.Runtime.InteropServices.GuidAttribute)assembly.GetCustomAttributes(
typeof(System.Runtime.InteropServices.GuidAttribute),false)[0]).Value
Note that you can use this method to get any of the various attributes in
the Assembly, as long as you know the type of the attribute, and what
member of the class you want to get at.
--
HTH,
Kevin Spencer
Microsoft MVP
Bit Player
http://unclechutney.blogspot.com
A pea rants as candy be sieving.
Ron M. Newman said:Hi: How do I get the GUID string out of an assembly? (I have it loaded
and referenced from an Assembly obect).
-Ron
Using this method I am able to read "Guid", "AssemblyFileVersion", but NOT
"AssemblyVersion". Any ideas why that is? is it not going into the compiled
file?
Ron M. Newman said:[assembly: Guid("6a6bf2ba-b251-492d-83c1-def446287453")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Using this method I am able to read "Guid", "AssemblyFileVersion", but NOT
"AssemblyVersion". Any ideas why that is? is it not going into the
compiled file?
I'm getting "index out of array" indicating this has not been found:
this.version =
((AssemblyVersionAttribute)this.myAssembly.GetCustomAttributes(typeof(AssemblyVersionAttribute),
false)[0]).Version;
-Ron
Kevin Spencer said:This is an attribute in the Assembly Manifest. You get to it by getting
an instance of the System.Reflection.Assembly class, using:
System.Reflection.Assembly assembly = Assembly.GetExecutingAssembly();
Then you get an Attribute from the assembly using the
Assembly.GetCustomAttributes method:
((System.Runtime.InteropServices.GuidAttribute)assembly.GetCustomAttributes(
typeof(System.Runtime.InteropServices.GuidAttribute),false)[0]).Value
Note that you can use this method to get any of the various attributes in
the Assembly, as long as you know the type of the attribute, and what
member of the class you want to get at.
--
HTH,
Kevin Spencer
Microsoft MVP
Bit Player
http://unclechutney.blogspot.com
A pea rants as candy be sieving.
Ron M. Newman said:Hi: How do I get the GUID string out of an assembly? (I have it loaded
and referenced from an Assembly obect).
-Ron