Exemplo n.º 1
0
        private static System.Reflection.Assembly AssemblyResolver(object sender, ResolveEventArgs args)
        {
            string exePath = System.IO.Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().GetName().CodeBase).LocalPath);

            string[] DirectoryList =
            {
                exePath,                                                     //App Folder
                System.IO.Path.Combine(exePath, "Plugins"),                  //App/Plugins Folder
                System.IO.Path.Combine(exePath, "Plugins", args.Name),       //App/Plugins/PluginName Folder
                Environment.SystemDirectory,                                 //System32 Folder
                Environment.GetFolderPath(Environment.SpecialFolder.Windows) //Windows Folder
            };

            System.Reflection.Assembly assembly = null;
            foreach (string path in DirectoryList)
            {
                if (TryGetAssembly(path, args.Name, out assembly))
                {
                    return(assembly);
                }
            }

            PluginLogger.Error("{0} could not be found in any of the following locations:\r\n\t{1}\r\n\t{2}\r\n\t{3}\r\n\t{4}\r\n\t{5}\r\n", (new string[] { args.Name }).Concat(DirectoryList).ToArray());
            return(null);
        }
Exemplo n.º 2
0
        public static Bitmap getImage(Assembly assembly, string Name)
        {
            Bitmap image = null;

            if (ResourceManager.ContainsKey(assembly))
            {
                image = (Bitmap)ResourceManager[assembly].GetObject(Name);
            }
            if (image is null)
            {
                PluginLogger.Error("'{0}' does not contain an image resource named '{1}'", assembly.GetName().Name, Name);
            }
            return(image);
        }