For the last couple of months I have working on Visual Studio 2010 and this include Microsoft CLR v4 and I was recently asked how to write a test that determines at runtime which CLR is being used and what assemblies it uses. I replies would use reflection. So I dropped my friend a mega simple demo… and here it is.
$set ilusing"System.Reflection"
01 myAssembly type "Assembly".
01 usedAssemblyName type "AssemblyName".
set myAssembly to type "Assembly"::"GetExecutingAssembly"
display "My exe is " myAssembly::"FullName"
display "and is using CLR " myAssembly::"ImageRuntimeVersion"
display "and is loaded from " myAssembly::"Location"
display "the initial method of this program was "
myAssembly::"EntryPoint"::"Name"
display "This assembly references -> "
perform varying usedAssemblyName
through myAssembly::"GetReferencedAssemblies"
display "-> " usedAssemblyName
end-perform
And the output of the program is:
My exe is clrver, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
and is using CLR v2.0.50727
and is loaded from d:clrver.exe
the initial method of this program was _MF_ENTRYThis assembly references ->
-> mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-> MicroFocus.COBOL.Runtime, Version=3.6.0.0, Culture=neutral,
PublicKeyToken=0412c5e0b2aaa8f0