private void LoadPlugins(List <string> lFiles, string strTypeName, string strDisplayFilePath, bool bSkipCacheFiles) { string strCacheRoot = UrlUtil.EnsureTerminatingSeparator( PlgxCache.GetCacheRoot(), false); foreach (string strFile in lFiles) { if (bSkipCacheFiles && strFile.StartsWith(strCacheRoot, StrUtil.CaseIgnoreCmp)) { continue; } FileVersionInfo fvi = null; try { fvi = FileVersionInfo.GetVersionInfo(strFile); if ((fvi == null) || (fvi.ProductName == null) || (fvi.ProductName != AppDefs.PluginProductName)) { continue; } } catch (Exception) { continue; } Exception exShowStd = null; try { string strHash = Convert.ToBase64String(CryptoUtil.HashSha256( strFile), Base64FormattingOptions.None); PluginInfo pi = new PluginInfo(strFile, fvi, strDisplayFilePath); pi.Interface = CreatePluginInstance(pi.FilePath, strTypeName); CheckCompatibility(strHash, pi.Interface); // CheckCompatibilityRefl(strFile); if (!pi.Interface.Initialize(m_host)) { continue; // Fail without error } m_vPlugins.Add(pi); } catch (BadImageFormatException exBif) { if (Is1xPlugin(strFile)) { MessageService.ShowWarning(KPRes.PluginIncompatible + MessageService.NewLine + strFile + MessageService.NewParagraph + KPRes.Plugin1x + MessageService.NewParagraph + KPRes.Plugin1xHint); } else { exShowStd = exBif; } } catch (Exception exLoad) { if (Program.CommandLineArgs[AppDefs.CommandLineOptions.Debug] != null) { MessageService.ShowWarningExcp(strFile, exLoad); } else { exShowStd = exLoad; } } if (exShowStd != null) { ShowLoadError(strFile, exShowStd, null); } } }
private void LoadPlugins(List <FileInfo> lFiles, string strTypeName, string strDisplayFilePath, bool bSkipCacheFiles) { string strCacheRoot = PlgxCache.GetCacheRoot(); foreach (FileInfo fi in lFiles) { if (bSkipCacheFiles && fi.FullName.StartsWith(strCacheRoot, StrUtil.CaseIgnoreCmp)) { continue; } FileVersionInfo fvi = null; try { fvi = FileVersionInfo.GetVersionInfo(fi.FullName); if ((fvi == null) || (fvi.ProductName == null) || (fvi.ProductName != AppDefs.PluginProductName)) { continue; } } catch (Exception) { continue; } Exception exShowStd = null; try { PluginInfo pi = new PluginInfo(fi.FullName, fvi, strDisplayFilePath); pi.Interface = CreatePluginInstance(pi.FilePath, strTypeName); if (!pi.Interface.Initialize(m_host)) { continue; // Fail without error } m_vPlugins.Add(pi); } catch (BadImageFormatException exBif) { if (Is1xPlugin(fi.FullName)) { MessageService.ShowWarning(KPRes.PluginIncompatible + MessageService.NewLine + fi.FullName + MessageService.NewParagraph + KPRes.Plugin1x + MessageService.NewParagraph + KPRes.Plugin1xHint); } else { exShowStd = exBif; } } catch (Exception exLoad) { if (Program.CommandLineArgs[AppDefs.CommandLineOptions.Debug] != null) { MessageService.ShowWarningExcp(fi.FullName, exLoad); } else { exShowStd = exLoad; } } if (exShowStd != null) { ShowLoadError(fi.FullName, exShowStd, null); } } }