コード例 #1
0
/// <summary>
/// Update & Load client assembly containing class as necessary
/// </summary>
/// <param name="className"></param>

        public static void LoadClientAssembly
            (string className)
        {
            if (ClientAssembliesLoaded == null)
            {
                ClientAssembliesLoaded = new Dictionary <string, object>();
            }

            ExtensionPoint ep = GetExtensionPointByClassName(className);

            if (ep == null)
            {
                return;
            }
            Plugin p = ep.Plugin;

            foreach (string assemblyName in p.RunTimeLibraries)
            {
                if (ClientAssembliesLoaded.ContainsKey(assemblyName))
                {
                    continue;                               // just continue if already loaded
                }
                string clientAssemblyPath =                 // path to assembly on client
                                            ClientDirs.StartupDir + @"\" + Path.GetFileName(assemblyName);
                string clientVersion = SystemUtil.GetAssemblyVersion(clientAssemblyPath);

                //string serverAssemblyPath = assemblyName; // path to assembly on server
                //if (!Path.IsPathRooted(serverAssemblyPath)) // if not rooted look in plugin dir for assembly
                //  serverAssemblyPath = p.Directory + @"\" + assemblyName;

                //bool serverAssemblyExists = File.Exists(serverAssemblyPath);
                //if (!serverAssemblyExists) // if not there try in server startup path
                //{
                //  serverAssemblyPath = ProcessState.ServerStartupPath + @"\" + assemblyName;
                //  serverAssemblyExists = File.Exists(serverAssemblyPath);
                //}

                //if (serverAssemblyExists)
                //{ // if found on server see if same version on client otherwise assume standard part of client assembly sets
                //  AssemblyName an = AssemblyName.GetAssemblyName(serverAssemblyPath);
                //  string serverVersion = an.Version.ToString();

                //  if (clientVersion != serverVersion) // download newer assembly if needed
                //    Client.PutFile(serverAssemblyPath, clientAssemblyPath);
                //}

                SystemUtil.LoadAssembly(clientAssemblyPath);

                ClientAssembliesLoaded[assemblyName] = null;                 // add to dict of loaded assemblies
            }
            return;
        }