private static List <Assembly> GetAssemblies(IEnumerable <string> fileList, ILogger logger) { var assemblies = new List <Assembly>(); foreach (var file in fileList) { try { var assemblyName = new AssemblyName(Path.GetFileNameWithoutExtension(file)); assemblies.Add(AssemblyLoadContext.Default.LoadFromAssemblyName(assemblyName)); } catch (BadImageFormatException e) { e.Data.Add("PluginsLocation", PluginsLocation); e.Data.Add("file", file); e.Data.Add("netFramework", GetDotNetVersion.Get45PlusFromRegistry()); logger?.Log(e, LogLevel.Error); } catch (COMException) { if (file.Contains("osuOverlayPlugin")) { var nl = Environment.NewLine; MessageBox.Show("Since SC version 190426.18, osu! overlay plugin started being falsely detected as virus" + nl + nl + "If you don't use it it is advised to just remove it from SC plugins folder (search for osuOverlayPlugin.dll and osuOverlay.dll inside SC folder)." + nl + nl + "However if you do use it, add these to your antivirus exceptions." + nl + nl + nl + "osu! overlay will NOT be loaded until you resolve this manually.", "StreamCompanion - WARNING", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { throw; } } catch (UnauthorizedAccessException) { MessageBox.Show( "StreamCompanion could not load any of the plugins because of not enough permissions." + Environment.NewLine + Environment.NewLine + "Please reinstall StreamCompanion.", "StreamCompanion - ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); Program.SafeQuit(); } } return(assemblies); }
public static void HandleException(Exception ex) { try { ex.Data.Add("netFramework", GetDotNetVersion.Get45PlusFromRegistry()); var errorConsensus = GetErrorData(); #if DEBUG WaitForDebugger(ex); #endif var errorResult = GetExceptionText(ex); foreach (var d in errorResult.Data) { ex.Data[d.Key] = d.Value; } #if WITHSENTRY if (errorConsensus.SendReport) { var ravenClient = SentryLogger.RavenClient; ravenClient.Release = ScVersion; var sentryEvent = new SentryEvent(ex); sentryEvent.Extra = SentryLogger.ContextData; ravenClient.Capture(sentryEvent); } #endif MessageBox.Show(errorConsensus.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); var form = new Error(errorResult.Text, null); form.ShowDialog(); } finally { try { SafeQuit(); } catch { _initializer.ExitThread(); } } }
private List <IPlugin> GetPlugins() { var files = Directory.GetFiles(PluginsLocation, "*.dll"); List <Assembly> assemblies = new List <Assembly>(); List <IPlugin> plugins = new List <IPlugin>(); foreach (var file in files) { try { var asm = Assembly.LoadFile(Path.Combine(PluginsLocation, file)); foreach (var type in asm.GetTypes()) { if (type.GetInterfaces().Contains(typeof(IPlugin))) { if (!type.IsAbstract) { assemblies.Add(asm); var p = Activator.CreateInstance(type) as IPlugin; plugins.Add(p); } } } } catch (BadImageFormatException e) { e.Data.Add("PluginsLocation", PluginsLocation); e.Data.Add("file", file); e.Data.Add("netFramework", GetDotNetVersion.Get45PlusFromRegistry()); _logger.Log(e, LogLevel.Error); } } return(plugins); }
public static void HandleException(Exception ex) { try { ex.Data.Add("netFramework", GetDotNetVersion.Get45PlusFromRegistry()); var errorConsensus = GetErrorData(); #if DEBUG WaitForDebugger(ex); #endif var errorResult = GetExceptionText(ex); foreach (var d in errorResult.Data) { ex.Data[d.Key] = d.Value; } //also reports to sentry if enabled MainLogger.Instance.Log(ex, LogLevel.Critical); MessageBox.Show(errorConsensus.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); var form = new Error(errorResult.Text, null); form.ShowDialog(); } finally { try { SafeQuit(); } catch { _initializer.ExitThread(); } } }
public static void Main() { GetDotNetVersion.Get45PlusFromRegistry(); }
public static void Main() { GetDotNetVersion.Get45PlusFromRegistry(); Console.ReadKey(); }