private void collectComponentVersions() { const string NEW_LINE = "\n"; const string SEMI_COLON = ";"; StringBuilder sb = new StringBuilder(4096); StringBuilder md5base = new StringBuilder(4096); List <Assembly> assemblies = new List <Assembly>(); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { if (null == assembly || assembly.IsDynamic) { continue; } assemblies.Add(assembly); } // Sort all the assemblies, so that the checksum over all of them is the same across all machines. assemblies.Sort(delegate(Assembly a, Assembly b) { if (null == a && null == b) { return(0); } else if (null == a) { return(-1); } else if (null == b) { return(1); } else { try { string aFileName = GetFileNameFromLocation(a.Location); string bFileName = GetFileNameFromLocation(b.Location); return(aFileName.CompareTo(bFileName)); } catch (Exception ex1) { try { Cat.lastException = ex1; return(a.FullName.CompareTo(b.FullName)); } catch (Exception ex2) { Cat.lastException = ex2; return(0); } } } }); foreach (var assembly in assemblies) { try { string location = assembly.Location; FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); string fileVersion = fileVersionInfo.FileVersion.ToString(); string productVersion = fileVersionInfo.ProductVersion.ToString(); string fileName = GetFileNameFromLocation(location); sb.Append(location).Append("?"); md5base.Append(fileName).Append("?"); // md5base does not consider full path but only file name. sb.Append("v=").Append(fileVersion).Append(SEMI_COLON); // md5base does not consider fileVersion but only productVersion sb.Append("pv=").Append(productVersion).Append(SEMI_COLON); md5base.Append(productVersion).Append(SEMI_COLON); FileInfo fileInfo = new FileInfo(location); if (fileInfo.Exists) { sb.Append("size=").Append(fileInfo.Length).Append(NEW_LINE); md5base.Append(fileInfo.Length).Append(NEW_LINE); } else { sb.Append(NEW_LINE); md5base.Append(NEW_LINE); } } catch (Exception ex) { Cat.lastException = ex; } } ; componentVersions = sb.ToString(); try { componentsChecksum = MD5Util.Compute(md5base.ToString()); } catch (Exception ex) { Cat.lastException = ex; } }