Пример #1
0
        public void Initialize()
        {
            //Load Default Assemblies
            foreach (Assembly assembly in ChoAssembly.GetLoadedAssemblies())
            {
                if (_loadedAssemblies.ContainsKey(assembly.FullName))
                {
                    continue;
                }
                _loadedAssemblies.Add(assembly.FullName, assembly);
            }

            LoadAssemblies(ChoCodeBase.Me.Paths);
        }
Пример #2
0
        public bool Initialize(bool beforeFieldInit, object state)
        {
            if (beforeFieldInit)
            {
                return(false);
            }

            //Load Default Assemblies
            foreach (Assembly assembly in ChoAssembly.GetLoadedAssemblies())
            {
                if (_loadedAssemblies.ContainsKey(assembly.FullName))
                {
                    continue;
                }
                _loadedAssemblies.Add(assembly.FullName, assembly);
            }

            LoadAssemblies(ChoCodeBase.Me.Paths);

            return(false);
        }
Пример #3
0
        private static Assembly LoadAssemblyFromResource(string name)
        {
            //Assembly thisAssembly = Assembly.GetEntryAssembly();

            foreach (Assembly thisAssembly in ChoAssembly.GetLoadedAssemblies())
            {
                if (thisAssembly.IsDynamic)
                {
                    continue;
                }
                try
                {
                    //Load form Embedded Resources - This Function is not called if the Assembly is in the Application Folder
                    var resources = thisAssembly.GetManifestResourceNames().Where(s => s.EndsWith(name));
                    if (resources.Count() > 0)
                    {
                        var resourceName = resources.First();
                        using (Stream stream = thisAssembly.GetManifestResourceStream(resourceName))
                        {
                            if (stream == null)
                            {
                                return(null);
                            }
                            var block = new byte[stream.Length];
                            stream.Read(block, 0, block.Length);
                            return(Assembly.Load(block));
                        }
                    }
                }
                catch (Exception ex)
                {
                    ChoTrace.Error(ex);
                }
            }
            return(null);
        }