private void AppDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args) { try { SessionAssemblyInfo newAssembly = RecordAssembly(args.LoadedAssembly); //only log it if we got a new assembly back - otherwise it was a dupe or irrelevant. if (newAssembly != null) { string location = newAssembly.Location; if (string.IsNullOrEmpty(location)) { if (Log.SessionSummary.PrivacyEnabled) { location = "(suppressed for privacy)"; } else { location = "(unknown)"; } } LogEvent(LogMessageSeverity.Verbose, "System.Events.Assembly", (string.IsNullOrEmpty(newAssembly.Name) ? "New Assembly Loaded" : "New Assembly Loaded - " + newAssembly.Name), "Name: {0}\r\nFull name: {1}\r\nLocation: {2}\r\n", newAssembly.Name, newAssembly.FullName, location); } } catch { } }
private SessionAssemblyInfo RecordAssembly(Assembly newAssembly) { SessionAssemblyInfo newSessionAssemblyInfo = null; lock (m_AssemblyLock) // a little pathological locking in case we get an assembly load event. { string fullName = newAssembly.FullName; if ((string.IsNullOrEmpty(fullName) == false) && (m_Assemblies.ContainsKey(fullName) == false)) { newSessionAssemblyInfo = new SessionAssemblyInfo(newAssembly, Log.SessionSummary.PrivacyEnabled == false); m_Assemblies.Add(fullName, newSessionAssemblyInfo); Log.Write(newSessionAssemblyInfo.Packet); } System.Threading.Monitor.PulseAll(m_AssemblyLock); } return(newSessionAssemblyInfo); }