Reflection in Dot Net

GET ASSEMBLY(Currently executing OR With Location) INFORMATION
 
Add following NameSpace
using System.Reflection;
 
Now write code in code file as per your requirement.
 
        string strFile_URL_Path = string.Empty;
        string strFilePath = string.Empty;
        string strVersionNo = string.Empty;
        string strAssemblyName = string.Empty;
        string strCultureInfo = string.Empty;
        //Find Information Of Executing Assembly
        Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;       //GET VERSION NO
        strVersionNo = v.ToString();
        strCultureInfo = System.Reflection.Assembly.GetExecutingAssembly().GetName().CultureInfo.ToString();
        object[] ar = new object[] { };
        ar = System.Reflection.Assembly.GetExecutingAssembly().GetReferencedAssemblies();   //Get All Referenced Assembly Object From Current assembly
        //Find Information With Location of assembly
        AssemblyName anm = AssemblyName.GetAssemblyName("c:\\Sharjeel.dll");
        strFile_URL_Path = anm.CodeBase;             //Get Complete Assembly path as  URL
        strFilePath = anm.CultureInfo.ToString();    // Get Assembly Culture Information
        strAssemblyName = anm.FullName.ToString();     //Get full name including version, token
 
 
 
 
GET METHOD INFO FROM ASSEMBLY
 
Add following NameSpace
using System.Diagnostics;
Now write following Code
 
        System.Diagnostics.StackFrame sf = new System.Diagnostics.StackFrame(1);
        System.Reflection.MethodBase mb = sf.GetMethod();
        string assemblyName = mb.DeclaringType.Assembly.GetName().Name;
        string Method = mb.DeclaringType.Name + "." + mb.Name + "()";
 
 
 
 GET CURRENT METHOD NAME & PARAMETERS OF THAT METHOD IN CODE FILE:
 
string CurrentMethodName = System.Reflection.MethodBase.GetCurrentMethod().Name.ToString();
object[] ParametersOfMethos = new object[] { };
ParametersOfMethos = System.Reflection.MethodBase.GetCurrentMethod().GetParameters();
 
 
 

Comments

Popular posts from this blog

Error : DependencyManagement.dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.adobe.aem:uber-jar:jar:apis -> version 6.3.0 vs 6.4.0

ERROR Exception while handling event Sitecore.Eventing.Remote.PublishEndRemoteEventException: System.AggregateExceptionMessage: One or more exceptions occurred while processing the subscribers to the 'publish:end:remote'

Error : Sorry, there was an error : unauthorized_client in Sitecore 9.1 login