Esempio n. 1
0
 public void LoadAndRegister(LocalProcess process, ClassLoader classLoader, string libraryName, string fileName, bool shouldRegister)
 {
     try
     {
         if (!_filesCached.Contains(fileName))
         {
             Assembly assembly = LoadAssembyFromRemote(process, libraryName, fileName);
             if (shouldRegister && !classLoader.Assemblies.Contains(assembly.FullName))
             {
                 classLoader.RegisterAssembly(Catalog.LoadedLibraries[Engine.SystemLibraryName], assembly);
             }
             _assembliesCached.Add(fileName);
             _filesCached.Add(fileName);
         }
     }
     catch (IOException E)
     {
         _internalServer.LogError(E);
     }
 }
Esempio n. 2
0
        public void ClassLoaderMissed(LocalProcess AProcess, ClassLoader AClassLoader, ClassDefinition AClassDefinition)
        {
            AcquireCacheLock(AProcess, LockMode.Exclusive);
            try
            {
                if (!AClassLoader.Classes.Contains(AClassDefinition.ClassName))
                {
                    // The local process has attempted to create an object from an unknown class alias.
                    // Use the remote server to attempt to download and install the necessary assemblies.
                    //string AFullClassName = AProcess.RemoteProcess.GetClassName(AClassDefinition.ClassName); // BTR 5/17/2004 -> As far as I can tell, this doesn't do anything

                    // Retrieve the list of all files required to load the assemblies required to load the class.
                    ServerFileInfo[] LFileInfos = AProcess.RemoteProcess.GetFileNames(AClassDefinition.ClassName, AProcess.Session.SessionInfo.Environment);

                    string[] LFullFileNames = new string[LFileInfos.Length];
                    for (int LIndex = 0; LIndex < LFileInfos.Length; LIndex++)
                    {
                        bool   LShouldLoad;
                        string LFullFileName = GetFile(AProcess, LFileInfos[LIndex].LibraryName, LFileInfos[LIndex].FileName, LFileInfos[LIndex].FileDate, LFileInfos[LIndex].IsDotNetAssembly, out LShouldLoad);

                        // Register/Load the assembly if necessary
                        if ((LFileInfos[LIndex].ShouldRegister || LShouldLoad) && !_assembliesCached.Contains(LFileInfos[LIndex].FileName))
                        {
                            Assembly LAssembly = Assembly.LoadFrom(LFullFileName);
                            ReflectionUtility.RegisterAssembly(LAssembly);
                            if (LFileInfos[LIndex].ShouldRegister && !AClassLoader.Assemblies.Contains(LAssembly.FullName))
                            {
                                AClassLoader.RegisterAssembly(Catalog.LoadedLibraries[Engine.SystemLibraryName], LAssembly);
                            }
                            _assembliesCached.Add(LFileInfos[LIndex].FileName);
                        }
                    }
                }
            }
            finally
            {
                ReleaseCacheLock(AProcess, LockMode.Exclusive);
            }
        }