static bool RegisterReferencedAssembliesToGAC()
        {
            List <string> assemblies = new List <string>(RegistrationToGACAssemblies);

            bool result = true;

            foreach (string assemblyName in assemblies)
            {
                string name = assemblyName;

                // This is a signed assembly, so unregister it to GAC.
                if (GACHelper.AddAssemblyToCache(assemblyName + ".dll") != 0)
                {// Error in registration.
                    UnregisterReferencedAssembliesFromGAC();

                    Console.WriteLine("ERROR - registration to GAC failed [" + assemblyName + "].");

                    result = false;
                    continue;
                }
                else
                {
                    Console.WriteLine("Registered to GAC [" + assemblyName + "].");
                }
            }

            return(result);
        }
        static void UnregisterReferencedAssembliesFromGAC()
        {
            List <string> assemblies = new List <string>(RegistrationToGACAssemblies);

            assemblies.AddRange(AdditionalUnRegistrationToGACAssemblies);

            foreach (string assemblyName in assemblies)
            {
                string name = assemblyName;

                // This is a signed assembly, so unregister it to GAC.
                int intResult = GACHelper.RemoveAssemblyFromCache(assemblyName);
            }
        }