Search code examples
.netvalidationstrongname

Validate Strong Name of Running Assembly


Is it possible for one to check the strong name of a .NET application that is already currently running separately from your own running applications process?


EDIT: For clarification, a solution that does not require a hard coded path to the executing assembly would be the most ideal solution.


EDIT #2: Is there any way to do this without using reflection?


Solution

  • Does this give you what you are looking for?

        Process[] processlist = Process.GetProcesses();
    
        foreach(Process theprocess in processlist)
        {
            string strongName = "N/A";
            try
            {
                strongName = Assembly.ReflectionOnlyLoadFrom(theprocess.MainModule.FileName).FullName;
            }
            catch
            {
                // System process?
            }
            Console.WriteLine("Process: {0} ID: {1} Strong Name: {2}", theprocess.ProcessName, theprocess.Id, strongName);
        }