WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

System_Reflection

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Get Assembly Properties

 Keywords:  Get Assembly Properties Information LoadFrom Reflection CodeBase System.Reflection System.Reflection.Assembly dotNetCollection2List dotNetGetEnumerator

;***************************************************************************
;** 
;**       Get Assembly Properties
;** 
;** Purpose: Gets information about an assembly
;** Inputs:  Assembly filename
;** Outputs: WIL Dialog with Array results in Reportview 
;** Revisions: Deana Falk 
;**            2013.05.03 Initial Code
;**            2013.05.07 Removed ObjectClrOption Use System.Reflection because 
;**                       it is unnecessary. Already loaded by mscorlib
;***************************************************************************

If Version( )< '2013A'
   Pause("Notice", "Need 2013A or Newer Version of WInBatch")
   Exit
EndIf

#DefineFunction dotNetCollection2List(collection, delimiter)
   list = ''
   ForEach oitem in collection
       data = oitem.ToString()
       if data == "" then list = data
       else list = list:delimiter:data
   Next
   ; 3053 Character string too long >2048
   If StrLen(list)>2048 then list = 'TOO LARGE TO DISPLAY'
   Return list
#Endfunction 

#DefineFunction dotNetGetEnumerator(object, delimiter) 
   Enum = object.GetEnumerator()
   list = ''
   While Enum.MoveNext()
     data = Enum.Current.ToString()
     if data == "" then list = data
     else list = list:delimiter:data
     Break
   EndWhile
   Return list
#Endfunction 

assemblyfilename = 'C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'

oAssembly = ObjectClrNew( 'System.Reflection.Assembly' )
oAssembly = oAssembly.LoadFrom( assemblyfilename )

;Create a 2 dim array, with a header, containing data
aProps  = ArrDimension(20,2)
aProps[0,0]  =  'Property' 
aProps[0,1]  =  'Value
aProps[1,0]  =  'CodeBase'
aProps[1,1]  =  oAssembly.CodeBase  ;Gets the location of the assembly as specified originally, for example, in an AssemblyName object.  
aProps[2,0]  =  'CustomAttributes'
aProps[2,1]  =  dotNetCollection2List( oAssembly.CustomAttributes, ',') ;Gets a collection that contains this assembly's custom attributes. 
aProps[3,0]  =  'DefinedTypes'
aProps[3,1]  =  dotNetCollection2List( oAssembly.DefinedTypes, ',') ;Gets a collection of the types defined in this assembly.
aProps[4,0]  =  'EntryPoint'
aProps[4,1]  =  oAssembly.EntryPoint  ;Gets the entry point of this assembly.  
aProps[5,0]  =  'EscapedCodeBase' 
aProps[5,1]  =  oAssembly.EscapedCodeBase  ;Gets the URI, including escape characters, that represents the codebase.  
aProps[6,0]  =  'Evidence'
aProps[6,1]  =  dotNetGetEnumerator(oAssembly.Evidence, ','); ObjectClrType ('System.Security.Policy.Evidence', oAssembly.Evidence)  ;Gets the evidence for this assembly.
aProps[7,0]  =  'ExportedTypes'
aProps[7,1]  =  dotNetCollection2List( oAssembly.ExportedTypes, ',') ;Gets a collection of the public types defined in this assembly that are visible outside the assembly. 
aProps[8,0]  =  'FullName'
aProps[8,1]  =  oAssembly.FullName  ;Gets the display name of the assembly.  
aProps[9,0]  =  'GlobalAssemblyCache' 
aProps[9,1]  =  oAssembly.GlobalAssemblyCache  ;Gets a value indicating whether the assembly was loaded from the global assembly cache.  
aProps[10,0] =  'HostContext'
aProps[10,1] =  oAssembly.HostContext  ;Gets the host context with which the assembly was loaded.  
aProps[11,0] =  'ImageRuntimeVersion'
aProps[11,1] =  oAssembly.ImageRuntimeVersion  ;Gets a string representing the version of the common language runtime (CLR) saved in the file containing the manifest.
aProps[12,0] =  'IsDynamic'
aProps[12,1] =  oAssembly.IsDynamic  ;Gets a value that indicates whether the current assembly was generated dynamically in the current process by using reflection emit.  
aProps[13,0] =  'IsFullyTrusted'                                                                                                                                                             
aProps[13,1] =  oAssembly.IsFullyTrusted  ;Gets a value that indicates whether the current assembly is loaded with full trust.                                                               
aProps[14,0] =  'Location'                                                                                                                                                                   
aProps[14,1] =  oAssembly.Location  ;Gets the full path or UNC location of the loaded file that contains the manifest.                                                                       
aProps[15,0] =  'ManifestModule'                                                                                                                                                             
aProps[15,1] =  oAssembly.ManifestModule.ToString()  ;Gets the module that contains the manifest for the current assembly.                                                                   
aProps[16,0] =  'Modules'                                                                                                                                                                    
aProps[16,1] =  dotNetCollection2List( oAssembly.Modules, ',')  ;Gets a collection that contains the modules in this assembly.                                                               
aProps[17,0] =  'PermissionSet'                                                                                                                                                              
aProps[17,1] =  dotNetGetEnumerator(oAssembly.PermissionSet, ',') ;Gets the grant set of the current assembly.                                                                                          
aProps[18,0] =  'ReflectionOnly'                                                                                                                                                             
aProps[18,1] =  oAssembly.ReflectionOnly  ;Gets a Boolean value indicating whether this assembly was loaded into the reflection-only context.                                                
aProps[19,0] =  'SecurityRuleSet'                                                                                                                                                            
aProps[19,1] =  oAssembly.SecurityRuleSet ; Gets a value that indicates which set of security rules the common language runtime (CLR) enforces for this assembly.  

MyDialogFormat=`WWWDLGED,6.2`

MyDialogCaption=`Assembly Properties`
MyDialogX=002
MyDialogY=059
MyDialogWidth=766
MyDialogHeight=353
MyDialogNumControls=003
MyDialogProcedure=`DEFAULT`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`231,333,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`499,333,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`019,011,706,298,REPORTVIEW,"ReportView_1",aProps,DEFAULT,DEFAULT,30,3145728,DEFAULT,DEFAULT,"192|192|192"`

ButtonPushed=Dialog("MyDialog")
Exit 

Article ID:   W17839
Filename:   Get Assembly Properties.txt
File Created: 2013:05:07:08:05:28
Last Updated: 2013:05:07:08:05:28