コード例 #1
0
        private void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
        {
            if (this.AssemblyLoaded != null)
            {
                this.AssemblyLoaded(this, new AssemblyLoadedEventArgs(args.LoadedAssembly));
            }

            Logs.Core.Write("Assembly loaded: {0}", LogFormat.Assembly(args.LoadedAssembly));
        }
コード例 #2
0
        private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            // First, trigger a resolve event and see if we found a matching Assembly.
            // This will give core and editor plugin managers to load plugin Assemblies
            // their own way, or resolve with an already loaded one.
            if (this.AssemblyResolve != null)
            {
                AssemblyResolveEventArgs resolveArgs = new AssemblyResolveEventArgs(args.Name);
                this.AssemblyResolve(this, resolveArgs);

                if (resolveArgs.IsResolved)
                {
                    return(resolveArgs.ResolvedAssembly);
                }
            }

            // Admit that we didn't find anything - unless it's a resource Assembly, which
            // is used for WinForms localization. Not finding them is the default / expected.
            bool isResourceAssembly = false;

            if (args.Name != null)
            {
                string token        = ".resources";
                int    index        = args.Name.IndexOf(token);
                int    pastEndIndex = index + token.Length;
                if (index != -1 && (pastEndIndex >= args.Name.Length || args.Name[pastEndIndex] == ','))
                {
                    isResourceAssembly = true;
                }
            }
            if (!isResourceAssembly)
            {
                if (args.RequestingAssembly != null)
                {
                    Logs.Core.WriteWarning(
                        "Can't resolve Assembly '{0}' (as requested by '{1}'): None of the available assembly paths matches the requested name.",
                        args.Name,
                        LogFormat.Assembly(args.RequestingAssembly));
                }
                else
                {
                    Logs.Core.WriteWarning(
                        "Can't resolve Assembly '{0}': None of the available assembly paths matches the requested name.",
                        args.Name);
                }
            }
            return(null);
        }