System.CodeDom.Compiler.Executor.GetRuntimeInstallDirectory C# (CSharp) Méthode

GetRuntimeInstallDirectory() static private méthode

static private GetRuntimeInstallDirectory ( ) : string
Résultat string
        internal static string GetRuntimeInstallDirectory() {
            return RuntimeEnvironment.GetRuntimeDirectory();
        }

Usage Example

        public static string GetCompilerPath(IDictionary <string, string> provOptions, string compilerExecutable)
        {
            // Get the location of the runtime, the usual answer
            string compPath = Executor.GetRuntimeInstallDirectory();

            // if provOptions is provided check to see if it alters what version we should bind to.
            // provOptions can be null if someone does new VB/CSCodeProvider(), in which case
            // they get the default behavior.
            if (provOptions != null)
            {
                string directoryPath;
                bool   directoryPathPresent = provOptions.TryGetValue(DirectoryPath, out directoryPath);
                string versionVal;
                bool   versionValPresent = provOptions.TryGetValue(NameTag, out versionVal);

                if (directoryPathPresent && versionValPresent)
                {
                    throw new InvalidOperationException(SR.GetString(SR.Cannot_Specify_Both_Compiler_Path_And_Version, DirectoryPath, NameTag));
                }

                // If they have an explicit path, use it.  Otherwise, look it up from the registry.
                if (directoryPathPresent)
                {
                    return(directoryPath);
                }

                // If they have specified a version number in providerOptions, use it.
                if (versionValPresent)
                {
                    switch (versionVal)
                    {
                    case RedistVersionInfo.InPlaceVersion:
                        // Use the RuntimeInstallDirectory, already obtained
                        break;

                    case RedistVersionInfo.RedistVersion:
                        // lock to the Orcas version, if it's not available throw (we'll throw at compile time)
                        compPath = GetCompilerPathFromRegistry(versionVal);
                        break;

                    case RedistVersionInfo.RedistVersion20:
                        //look up 2.0 compiler path from registry
                        compPath = GetCompilerPathFromRegistry(versionVal);
                        break;

                    default:
                        compPath = null;
                        break;
                    }
                }
            }

            if (compPath == null)
            {
                throw new InvalidOperationException(SR.GetString(SR.CompilerNotFound, compilerExecutable));
            }

            return(compPath);
        }
All Usage Examples Of System.CodeDom.Compiler.Executor::GetRuntimeInstallDirectory