void LoadDebugging(object sender, AssemblyLoadEventArgs args, string name)
        {
            // we'll output the full assemblyName
            Console.WriteLine("{0} was loaded:", args.LoadedAssembly.FullName);

            // can skip the first 2 frames,
            // they just have the event handlers for assem load
            StackTrace stackTrace = new StackTrace(2);
            StackFrame[] frames = stackTrace.GetFrames();

            // dump the stack
            foreach (StackFrame frame in frames)
            {
                MethodBase method = frame.GetMethod();
                ParameterInfo[] parameters = method.GetParameters();
                StringBuilder parString = new StringBuilder();
                for (int i = 0; i < parameters.Length; i++)
                {
                    ParameterInfo par = parameters[i];
                    if (i > 0)
                        parString.Append(", ");

                    parString.Append(par.ParameterType.ToString());
                }

                Console.WriteLine(" at {0}.{1}({2})",
                method.DeclaringType.Name,
                method.Name,
                parString.ToString());
            }
        }
예제 #2
0
 static void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
 {
     Assembly assembly = args.LoadedAssembly;
     lock (assemblies) {
         assemblies[assembly.FullName] = assembly;
     }
 }
예제 #3
0
        private void OnAssemblyLoad(object sender, AssemblyLoadEventArgs args)
        {
            if (args.LoadedAssembly.GlobalAssemblyCache)
                return;

            Trace.TraceInformation("Assembly Loaded... {0}", args.LoadedAssembly.Location);

            if (args.LoadedAssembly.Location.StartsWith(_pluginFolder.FullName, StringComparison.InvariantCultureIgnoreCase))
            {
                try
                {
                    RegisterWithCheck(args.LoadedAssembly);

                    var types = args.LoadedAssembly.GetExportedTypes();

                    if (types.Any())
                    {
                        foreach (var type in types)
                        {
                            Trace.TraceInformation("Type exported: {0}", type.FullName);
                        }
                    }
                    else
                    {
                        Trace.TraceInformation("No types exported by Assembly: '{0}'",
                            args.LoadedAssembly.GetName().Name);
                    }
                }
                catch (Exception ex)
                {
                    Trace.TraceInformation(ex.Message);
                }
            }
        }
        void LoadDebugging(object sender, AssemblyLoadEventArgs args, string name)
        {
            // can skip the first 2 frames,
            // they just have the event handlers for assem load
            StackTrace stackTrace = new StackTrace(2);
            StackFrame[] frames = stackTrace.GetFrames();

            // dump the stack
            foreach (StackFrame frame in frames)
            {
                MethodBase method = frame.GetMethod();
                ParameterInfo[] parameters = method.GetParameters();
                StringBuilder parString = new StringBuilder();
                for (int i = 0; i < parameters.Length; i++)
                {
                    ParameterInfo par = parameters[i];
                    if (i > 0)
                        parString.Append(", ");

                    parString.Append(par.ParameterType.ToString());
                }

                //LoggerFactory.Default.Log(AssemblyLoadMonitorLogID, " at " + method.DeclaringType.Name + "." + method.Name + "(" + parString.ToString() + ")");
            }
        }
 /// <summary>
 /// Handles the AssemblyLoad event of the AppDomain.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="args">The <see cref="AssemblyLoadEventArgs"/> instance containing the event data.</param>
 private void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
 {
     lock (this)
     {
         UpdateMap();
     }
 }
예제 #6
0
        private static void OnAssemblyLoaded(object sender, AssemblyLoadEventArgs args)
        {
            _assembliesByName[args.LoadedAssembly.FullName] = args.LoadedAssembly;
            _assembliesByIndex.Add(args.LoadedAssembly);

            _cachedTypes = new Dictionary<string, Type>();
        }
    private void OnAssemblyLoad(object sender, AssemblyLoadEventArgs args) {
        Assembly a = args.LoadedAssembly;

        // Ignore GAC assemblies
        if (a.GlobalAssemblyCache)
            return;

        // Ignore assemblies that don't start with our prefix
        string name = a.GetName().Name;
        if (!StringUtil.StringStartsWith(name, BuildManager.AssemblyNamePrefix))
            return;

        // Go through all the assemblies it references
        foreach (AssemblyName assemblyName in a.GetReferencedAssemblies()) {

            // Ignore references that don't start with our prefix
            if (!StringUtil.StringStartsWith(assemblyName.Name, BuildManager.AssemblyNamePrefix))
                continue;

            lock (_dependentAssemblies) {
                // Check whether we already have an ArrayList for this reference
                ArrayList dependentList = _dependentAssemblies[assemblyName.Name] as ArrayList;
                if (dependentList == null) {
                    // If not, create one and add it to the hashtable
                    dependentList = new ArrayList();
                    _dependentAssemblies[assemblyName.Name] = dependentList;
                }

                // Add the assembly that just got loaded as a dependent
                Debug.Assert(!dependentList.Contains(name));
                dependentList.Add(name);
            }
        }
    }
예제 #8
0
            private void AssemblyLoaded(object sender, AssemblyLoadEventArgs args) {
                // !!! BUG on .Net 2 SP1: going further breaks DefineDynamicAssembly in very strange manner, so don't process dynamic assemblies
                // simple test:
                // AppDomain.CurrentDomain.DefineDynamicAssembly(new System.Reflection.AssemblyName("dynBoxed" + Guid.NewGuid().ToString()), System.Reflection.Emit.AssemblyBuilderAccess.Run);
                // previous workaround using RegisterAssemblyForNonAutoRegistration/ShouldSkipAssemblyTypeAutoRegistration
                // is deficient, there may be dynamic assemblies irrelevant to IIOPNet.
                // So this patch is simple and universal:
                if (args.LoadedAssembly is System.Reflection.Emit.AssemblyBuilder)
                    return;

                RegisterTypes(args.LoadedAssembly);
                AssemblyName[] refAssemblies =
                    args.LoadedAssembly.GetReferencedAssemblies();
                if (refAssemblies != null) {
                    for (int i = 0; i <refAssemblies.Length; i++) {
                        try {
                            if (refAssemblies[i] != null) {
                                Assembly.Load(refAssemblies[i]); // this will call AssemblyLoaded for this assembly
                            }
                        } catch (BadImageFormatException) {
                            Trace.WriteLine("bad format -> ignoring assembly " + refAssemblies[i].FullName);
                            // ignore assembly
                        } catch (FileNotFoundException) {
                            Trace.WriteLine("missing -> ignoring assembly " + refAssemblies[i].FullName);
                            // ignore assembly
                        } catch (System.Security.SecurityException) {
                            Trace.WriteLine("security problem -> ignoring assembly " + refAssemblies[i].FullName);
                            // ignore assembly
                        }
                    }
                }
            }
 void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
 {
     foreach (var type in args.LoadedAssembly.GetTypes().Where(
             type => type.GetCustomAttributes(typeof(GuidAttribute), true).Any()))
     {
         this.types.TryAdd(type.GUID, type);
     }
 }
예제 #10
0
		private void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
		{
			if (IsPluginAssembly(args.LoadedAssembly))
			{
				var plugin = CreatePluginFromAssembly(args.LoadedAssembly);
				PublishPlugin(plugin);
			}
		}
예제 #11
0
#pragma warning restore 1591 // Xml Comments

        void AssemblyLoaded(object sender, AssemblyLoadEventArgs args)
        {
            var assembly = args.LoadedAssembly;
            if (!assembly.IsDynamic)
            {
                AvailableAssemblies.Add(AssemblyInfoFromAssembly(assembly));
            }
        }
예제 #12
0
 private static void OnAssemblyLoad(object sender, AssemblyLoadEventArgs args)
 {
     var asm = args.LoadedAssembly;
     if (!asm.IsDynamic)
     {
         Log.LogVerbose(nameof(PackageAssemblyHandler), $"Assembly loaded: {asm.Location}");
     }
 }
예제 #13
0
        public void AssemblyLoadedInCurrentDomain()
        {
            AssemblyLoadEventArgs assemblyEvent = new AssemblyLoadEventArgs(Assembly.GetAssembly(GetType()));
            BinaryDataFactory binaryDataFactory = new BinaryDataFactory();
            binaryDataFactory.OnAssemblyLoadInCurrentDomain(null, assemblyEvent);

            Assert.That(binaryDataFactory.shortNames.Count, Is.GreaterThanOrEqualTo(4));
            Assert.That(binaryDataFactory.typeMap.Count, Is.GreaterThanOrEqualTo(4));
        }
예제 #14
0
 static void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
 {
     if (!args.LoadedAssembly.GetName().Name.Contains("Proxies_"))
     {
         ConsoleColor CurrentColor = Console.ForegroundColor;
         Console.ForegroundColor = ConsoleColor.Yellow;
         Console.WriteLine(string.Format("Loading {0}.dll", args.LoadedAssembly.GetName().Name));
         Console.ForegroundColor = CurrentColor;
     }
 }
예제 #15
0
 private static void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
 {
     try
     {
         Logger.Log.DebugFormat("Assembly loaded: {0}", args.LoadedAssembly);
     }
     catch
     {
     }
 }
예제 #16
0
        public static void Loaded(object sender, AssemblyLoadEventArgs args)
        {
            loadedAssemblies.Add(args.LoadedAssembly);

            var dir = new FileInfo(args.LoadedAssembly.Location).Directory;
            if (!directories.Contains(dir.FullName))
            {
                directories.Add(dir.FullName);
            }
        }
 void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
 {
     try
     {
         var assm = args.LoadedAssembly;
         var aName = assm.GetName();
         this.TrackAssembly(aName);
     }
     catch { }
 }
예제 #18
0
 static void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
 {
     //AppDomain domain = sender as AppDomain;
     //string senderTxt = "-NA-";
     //if (domain != null)
     //    senderTxt = "domain " + domain.FriendlyName;
     //_tr.WriteLine("CurrentDomain_AssemblyLoad");
     //_tr.WriteLine("  sender                    {0}", senderTxt);
     //_tr.WriteLine("  args.LoadedAssembly       {0}", args.LoadedAssembly.FullName);
     _tr.WriteLine("Assembly loaded \"{0}\"", args.LoadedAssembly.FullName);
 }
예제 #19
0
        /// <summary>
        /// Ocorre toda vez que um assembly é carregado tardiamente.
        /// </summary>
        private void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
        {
            foreach (ExporBotãoAttribute exportação in 
                args.LoadedAssembly.GetCustomAttributes(typeof(ExporBotãoAttribute), true))
            {
                Botão botão = ExportarBotão(args.LoadedAssembly, exportação);

                if (botão != null)
                    botão.Controlador.AoCarregarCompletamente(null);
            }
        }
예제 #20
0
        static void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
        {
            var assembly = args.LoadedAssembly;
            var assemblyName = assembly.GetName();

            // Note that we load assembly by name, not full name
            // This means that we forgot the version number
            // we should handle the version number too,
            // but take into account that we want to deliver the assembly if we don't find the exact same version number
            assemblies.TryAdd(assemblyName.Name, assembly);
        }
예제 #21
0
        public static void AssemblyLoaded(object sender, AssemblyLoadEventArgs args)
        {
            string assemblyName = args.LoadedAssembly.GetName().Name;

             if (_searchedTypes.ContainsKey(assemblyName))
             {
            Log("!!! Assembly '"+ assemblyName + "' was loaded multiple times.");
            Log("    First Location: " + _searchedTypes[assemblyName].CodeBase);
            Log("    This Location : " + args.LoadedAssembly.CodeBase);
             }

             _searchedTypes[assemblyName] = args.LoadedAssembly;
        }
예제 #22
0
        private static void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
        {

            //AppDomain.CurrentDomain.GetAssemblies()[85].GetName().Name
            //if(args.LoadedAssembly.GetName().)
            if (args.LoadedAssembly.GetName().ToString().StartsWith("__Ideative"))
            {
                Debug.WriteLine(args.LoadedAssembly.GetName() + " ekleniyor");
                Debug.WriteLine(sender.ToString());
                AppDomain.CurrentDomain.Load(args.LoadedAssembly.GetName());
                var assbly = AppDomain.CurrentDomain.GetAssemblies().Where(ass => ass.GetName().Name == args.LoadedAssembly.GetName().Name);
            }
        }
예제 #23
0
        private static void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
        {
            if (args == null || args.LoadedAssembly == null || string.IsNullOrEmpty(args.LoadedAssembly.FullName))
                return;

            lock (_lock)
            {
                if (args.LoadedAssembly.FullName.StartsWith("EntityFrameworkDynamicProxies") &&
                    !_assembliesWithDynamicProxies.Contains(args.LoadedAssembly))
                {
                    //Types aren't generated yet, so we can't add them to _dynamixEntityProxies
                    _assembliesWithDynamicProxies.Add(args.LoadedAssembly);
                }
            }
        }
예제 #24
0
 static void domain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
 {
     bool knownLocation = args.LoadedAssembly.Location != null &&
                          robotAssemblyShadowFileName != null &&
                          Path.GetFullPath(args.LoadedAssembly.Location).ToLower() ==
                          Path.GetFullPath(robotAssemblyShadowFileName).ToLower();
     if (args.LoadedAssembly != typeof(Bridge).Assembly &&
         args.LoadedAssembly != typeof(AppDomainSeed).Assembly &&
         !knownLocation &&
         !args.LoadedAssembly.GlobalAssemblyCache)
     {
         string message = "dependent assemblies are not alowed" + args.LoadedAssembly.Location;
         LoggerN.logError(message);
         throw new SecurityException(message);
     }
 }
예제 #25
0
 private void HandleAssemblyLoad(object sender, AssemblyLoadEventArgs args)
 {
     var mdtype = typeof (SharpMap.Rendering.Decoration.IMapDecoration);
     foreach (Type type in args.LoadedAssembly.GetTypes())
     {
         //if (type.FullName.StartsWith("SharpMap.Decoration"))
         //    Console.WriteLine(type.FullName);
         if (mdtype.IsAssignableFrom(type))
         {
             if (!type.IsAbstract)
             {
                 if (AddToListView)
                     lvwDecorations.Items.Add(new ListViewItem(type.Name));
                 MapDecorationTypes.Add(type.Name, type);
             }
         }
     }
 }
예제 #26
0
 internal void FilterCallback(Object sender, AssemblyLoadEventArgs args) 
 {
     // This code is reentrant 
     lock (_lock)
     {
         // Extract assembly
         Assembly a = args.LoadedAssembly; 
         // xmlns cache loads assemblies as reflection only and we cannot inspect these using the code below
         // so we ignore also keeping this first is super important because the first time cost is really high 
         // other wise also we cannot do any processing on a reflection only assembly aside from reflection based actions 
         if (!a.ReflectionOnly)
         { 
             // check if it is in the Gac , this ensures that we eliminate any non GAC assembly which are of no risk
             if (a.GlobalAssemblyCache)
             {
                 object[] aptca = a.GetCustomAttributes(typeof(AllowPartiallyTrustedCallersAttribute), false); 
                 // if the dll has APTCA
                 if (aptca.Length > 0 && aptca[0] is AllowPartiallyTrustedCallersAttribute) 
                 { 
                     string assemblyName = AssemblyNameWithFileVersion(a);
                     // If we are on the disallowed list kill the application domain 
                     if (AssemblyOnDisallowedList(assemblyName))
                     {
                         // Kill the application domain
                         UnsafeNativeMethods.ProcessUnhandledException_DLL(SR.Get(SRID.KillBitEnforcedShutdown) + assemblyName); 
                         // I want to ensure that the process really dies
                         new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert();//BlessedAssert 
                         try 
                         {
                             System.Environment.Exit(-1); 
                         }
                         finally
                         {
                             SecurityPermission.RevertAssert(); 
                             Debug.Fail("Environment.Exit() failed.");
                         } 
                     } 
                 }
             } 
         }
     }
 }
예제 #27
0
파일: TypeCache.cs 프로젝트: pars87/Catel
        /// <summary>
        /// Called when an assembly is loaded in the current <see cref="AppDomain"/>.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="AssemblyLoadEventArgs" /> instance containing the event data.</param>
        private static void OnAssemblyLoaded(object sender, AssemblyLoadEventArgs args)
        {
            var assembly = args.LoadedAssembly;

            if (assembly.ReflectionOnly)
            {
                Log.Debug("Reflection '{0}' is loaded for reflection-only, cannot use this assembly", assembly.FullName);
                return;
            }

            InitializeTypes(false, assembly);

            var handler = AssemblyLoaded;
            if (handler != null)
            {
                var types = GetTypesOfAssembly(assembly);
                var eventArgs = new AssemblyLoadedEventArgs(assembly, types);

                handler(null, eventArgs);
            }
        }
예제 #28
0
 private static void ProcessNewAssembly(object sender, AssemblyLoadEventArgs args)
 {
     // We do this under the lock to avoid race conditions when an assembly is added
     // while a type manager is initializing.
     lock (managers)
     {
         // We assume that it's better to fetch and iterate through the list of types once,
         // and the list of TypeManagers many times, rather than the other way around.
         // Certainly it can't be *less* efficient to do it this way.
         foreach (var type in args.LoadedAssembly.DefinedTypes)
         {
             foreach (var mgr in managers)
             {
                 if (mgr.IsActive)
                 {
                     mgr.ProcessType(type);
                 }
             }
         }
     }
 }
 private void CurrentDomainAssemblyLoad(object sender, AssemblyLoadEventArgs e)
 {
     string loadedAssemblyName = e.LoadedAssembly.GetName().Name;
     if (loadedAssemblyName == "StyleCop")
     {
         this.styleCopLoaded = true;
         if (this.StyleCopLoaded)
         {
             LoadCRStyleCopPlugin();
         }
         return;
     }
     if (loadedAssemblyName == "StyleCop.CSharp")
     {
         this.styleCopCSharpLoaded = true;
         if (this.StyleCopLoaded)
         {
             LoadCRStyleCopPlugin();
         }
         return;
     }
     if (loadedAssemblyName == "StyleCop.CSharp.Rules")
     {
         this.styleCopCSharpRulesLoaded = true;
         if (this.StyleCopLoaded)
         {
             LoadCRStyleCopPlugin();
         }
         return;
     }
     if (loadedAssemblyName == "StyleCop.VSPackage")
     {
         this.styleCopVSPackageLoaded = true;
         if (this.StyleCopLoaded)
         {
             LoadCRStyleCopPlugin();
         }
         return;
     }
 }
예제 #30
0
		private static void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
		{
			var asm = args.LoadedAssembly;

			if (asm.IsDynamic || (asm is System.Reflection.Emit.AssemblyBuilder))
				return;
			try
			{
				// this will include only those assemblies that have an external file
				// we put this in a try .. catch clause since for some assemblies asking for the location will cause an UnsupportedException
				if (string.IsNullOrEmpty(asm.Location))
					return;
			}
			catch (Exception)
			{
				return;
			}

			// now our assembly is not a dynamic assembly, and has an an external file location
			lock (_startupAssemblies)
			{
				_startupAssemblies.Add(asm);
			}
		}