diff --git a/Greenshot/Helpers/PluginHelper.cs b/Greenshot/Helpers/PluginHelper.cs index cb863fd0a..429a47a8f 100644 --- a/Greenshot/Helpers/PluginHelper.cs +++ b/Greenshot/Helpers/PluginHelper.cs @@ -234,7 +234,7 @@ namespace Greenshot.Helpers { foreach (string pluginFile in pluginFiles) { LOG.DebugFormat("Checking the following file for plugins: {0}", pluginFile); try { - Assembly assembly = Assembly.LoadFile(pluginFile); + Assembly assembly = Assembly.LoadFile(pluginFile, Assembly.GetExecutingAssembly().Evidence); PluginAttribute[] pluginAttributes = assembly.GetCustomAttributes(typeof(PluginAttribute), false) as PluginAttribute[]; if (pluginAttributes.Length > 0) { PluginAttribute pluginAttribute = pluginAttributes[0]; diff --git a/GreenshotExternalCommandPlugin/ExternalCommandConfiguration.cs b/GreenshotExternalCommandPlugin/ExternalCommandConfiguration.cs index 0aa7f0c26..5dec70b8b 100644 --- a/GreenshotExternalCommandPlugin/ExternalCommandConfiguration.cs +++ b/GreenshotExternalCommandPlugin/ExternalCommandConfiguration.cs @@ -41,12 +41,21 @@ namespace ExternalCommand { public Dictionary arguments; private const string MSPAINT = "MS Paint"; - private static string paintPath = AbstractDestination.GetExePath("pbrush.exe"); - private static bool hasPaint = !string.IsNullOrEmpty(paintPath) && File.Exists(paintPath); + private static string paintPath; + private static bool hasPaint = false; private const string PAINTDOTNET = "Paint.NET"; - private static string paintDotNetPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Paint.NET\PaintDotNet.exe"); - private static bool hasPaintDotNet = !string.IsNullOrEmpty(paintDotNetPath) && File.Exists(paintDotNetPath); + private static string paintDotNetPath; + private static bool hasPaintDotNet = false; + static ExternalCommandConfiguration() { + try { + paintPath = AbstractDestination.GetExePath("pbrush.exe"); + hasPaint = !string.IsNullOrEmpty(paintPath) && File.Exists(paintPath); + paintDotNetPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Paint.NET\PaintDotNet.exe"); + hasPaintDotNet = !string.IsNullOrEmpty(paintDotNetPath) && File.Exists(paintDotNetPath); + } catch { + } + } /// /// Supply values we can't put as defaults diff --git a/GreenshotPlugin/Core/LanguageHelper.cs b/GreenshotPlugin/Core/LanguageHelper.cs index a7958c0b3..0ffebe65a 100644 --- a/GreenshotPlugin/Core/LanguageHelper.cs +++ b/GreenshotPlugin/Core/LanguageHelper.cs @@ -259,7 +259,7 @@ namespace GreenshotPlugin.Core { languageDirectories.Add(STARTUP_LANGUAGE_PATH); foreach(string path in languageDirectories) { // Search in executable directory - LOG.DebugFormat("Searching language directory '{0}' for language files with pattern '{1}'", path, languageFilePattern); + LOG.InfoFormat("Searching language directory '{0}' for language files with pattern '{1}'", path, languageFilePattern); try { foreach(string languageFile in Directory.GetFiles(path, languageFilePattern, SearchOption.AllDirectories)) { LOG.DebugFormat("Found language file: {0}", languageFile); @@ -284,7 +284,7 @@ namespace GreenshotPlugin.Core { // Try to force internal english try { LOG.Info("No languages found, using embedded en-US."); - using (Stream stream = Assembly.GetCallingAssembly().GetManifestResourceStream("Greenshot.Languages.language-en-US.xml")) { + using (Stream stream = Assembly.GetEntryAssembly().GetManifestResourceStream("Greenshot.Languages.language-en-US.xml")) { LanguageConfiguration languageConfig = LanguageConfiguration.Load(stream); if (languageConfig != null) { loadedLanguages.Add(languageConfig); diff --git a/GreenshotPlugin/IniFile/IniConfig.cs b/GreenshotPlugin/IniFile/IniConfig.cs index 321bdebcd..1070ad3ab 100644 --- a/GreenshotPlugin/IniFile/IniConfig.cs +++ b/GreenshotPlugin/IniFile/IniConfig.cs @@ -81,10 +81,10 @@ namespace IniFile { /// Default init /// public static void Init() { - AssemblyProductAttribute[] assemblyProductAttributes = Assembly.GetCallingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false) as AssemblyProductAttribute[]; + AssemblyProductAttribute[] assemblyProductAttributes = Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false) as AssemblyProductAttribute[]; if (assemblyProductAttributes.Length > 0) { string productName = assemblyProductAttributes[0].Product; - LOG.DebugFormat("Using ProductName {0}", productName); + LOG.InfoFormat("Using ProductName {0}", productName); Init(productName, productName); } else { throw new InvalidOperationException("Assembly ProductName not set."); @@ -160,7 +160,13 @@ namespace IniFile { throw new InvalidOperationException("IniConfig.Init not called!"); } string iniFilePath = null; - string applicationStartupPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + string applicationStartupPath = ""; + try { + applicationStartupPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + } catch (Exception exception) { + LOG.WarnFormat("Problem retrieving the AssemblyLocation: {0}", exception.Message); + applicationStartupPath = @"."; + } string pafPath = Path.Combine(applicationStartupPath, @"App\" + applicationName); if (portable || !portableCheckMade) {