Ejemplo n.º 1
0
        static void ReadParamFromReg(out string logFileName, out uint maxLogBuffers)
        {
            // Read log file location from registry if exists
            string logFileNameInRegistry = null;

            RegistryConfigurationProvider wsatTraceProvider = new RegistryConfigurationProvider(RegistryHive.LocalMachine, WsatKeys.WsatRegKey, null);

            using (wsatTraceProvider)
            {
                logFileNameInRegistry = wsatTraceProvider.ReadString(WsatKeys.TraceFileDiectoryKey, null);
                maxLogBuffers         = wsatTraceProvider.ReadUInt32(WsatKeys.MaxTraceBuffersKey, DefaultBuffers);

                if (maxLogBuffers == 0 || maxLogBuffers > MaxLogBuffers)
                {
                    maxLogBuffers = DefaultBuffers;
                    wsatTraceProvider.WriteUInt32(WsatKeys.MaxTraceBuffersKey, DefaultBuffers);
                }
            }

            String errLogFileName = String.Empty;

            try
            {
                if (!String.IsNullOrEmpty(logFileNameInRegistry))
                {
                    logFileNameInRegistry = logFileNameInRegistry.Trim();
                }

                if (!String.IsNullOrEmpty(logFileNameInRegistry))
                {
                    errLogFileName = logFileNameInRegistry;
                    logFileName    = Path.Combine(logFileNameInRegistry, DefaultLogFileName);
                }
                else
                {
                    errLogFileName = Environment.SystemDirectory;
                    logFileName    = Path.Combine(Environment.SystemDirectory, DafaultLogDirectory);
                    errLogFileName = logFileName;
                    logFileName    = Path.Combine(logFileName, DefaultLogFileName);
                }
            }
            catch (ArgumentException)
            {
                throw new WsatAdminException(WsatAdminErrorCode.ETW_SESSION_INVALID_LOGFILE_NAME,
                                             SR.GetString(SR.ErrorSessionInvalidLogFileName, errLogFileName));
            }

            if (logFileName.Length >= SafeNativeMethods.MaxTraceFileNameLen)
            {
                throw new WsatAdminException(WsatAdminErrorCode.ETW_SESSION_TOO_LONG_LOGFILE_NAME,
                                             SR.GetString(SR.ErrorSessionTooLongLogFileName, logFileName));
            }
        }
Ejemplo n.º 2
0
        internal string GetDeploymentPath()
        {
            string path = null;

            try
            {
                //We first check if the 4.0 install path was available.
                RegistryConfigurationProvider reg = new RegistryConfigurationProvider(Microsoft.Win32.RegistryHive.LocalMachine,
                                                                                      WsatKeys.WcfSetupKey40,
                                                                                      machineName);

                path = reg.ReadString(WsatKeys.RuntimeInstallPath, null);

                if (string.IsNullOrEmpty(path))
                {
                    //If path under 4.0 doesnt exit, check under 3.0
                    RegistryConfigurationProvider reg2 = new RegistryConfigurationProvider(Microsoft.Win32.RegistryHive.LocalMachine,
                                                                                           WsatKeys.WcfSetupKey,
                                                                                           machineName);

                    path = reg2.ReadString(WsatKeys.RuntimeInstallPath, null);
                    if (string.IsNullOrEmpty(path))
                    {
                        throw new WsatAdminException(WsatAdminErrorCode.CANNOT_GET_REMOTE_INSTALL_PATH,
                                                     SR.GetString(SR.ErrorCannotGetRemoteInstallPath));
                    }
                }

                path = Path.Combine(path, "WsatConfig.exe");
            }
            catch (WsatAdminException e)
            {
                throw new WsatAdminException(WsatAdminErrorCode.CANNOT_GET_REMOTE_INSTALL_PATH,
                                             SR.GetString(SR.ErrorCannotGetRemoteInstallPath), e);
            }
            catch (ArgumentException e) // if the path in the remote registry is invalid...
            {
                throw new WsatAdminException(WsatAdminErrorCode.CANNOT_GET_REMOTE_INSTALL_PATH,
                                             SR.GetString(SR.ErrorCannotGetRemoteInstallPath), e);
            }
            return(path);
        }
Ejemplo n.º 3
0
        internal string GetDeploymentPath()
        {
            string path = null;

            try
            {
                //We first check if the 4.0 install path was available.
                RegistryConfigurationProvider reg = new RegistryConfigurationProvider(Microsoft.Win32.RegistryHive.LocalMachine,
                    WsatKeys.WcfSetupKey40,
                    machineName);

                path = reg.ReadString(WsatKeys.RuntimeInstallPath, null);

                if (string.IsNullOrEmpty(path))
                {

             //If path under 4.0 doesnt exit, check under 3.0
                 RegistryConfigurationProvider reg2 = new RegistryConfigurationProvider(Microsoft.Win32.RegistryHive.LocalMachine,
                        WsatKeys.WcfSetupKey,
                machineName);

                 path = reg2.ReadString(WsatKeys.RuntimeInstallPath, null);
                 if (string.IsNullOrEmpty(path))
                 {
                    throw new WsatAdminException(WsatAdminErrorCode.CANNOT_GET_REMOTE_INSTALL_PATH,
                                                                    SR.GetString(SR.ErrorCannotGetRemoteInstallPath));
        
                 }

                }

                path = Path.Combine(path, "WsatConfig.exe");
            }
            catch (WsatAdminException e)
            {
                throw new WsatAdminException(WsatAdminErrorCode.CANNOT_GET_REMOTE_INSTALL_PATH,
                                                                SR.GetString(SR.ErrorCannotGetRemoteInstallPath), e);
            }
            catch (ArgumentException e) // if the path in the remote registry is invalid...
            {
                throw new WsatAdminException(WsatAdminErrorCode.CANNOT_GET_REMOTE_INSTALL_PATH,
                                                                SR.GetString(SR.ErrorCannotGetRemoteInstallPath), e);
            }
            return path;
        }
Ejemplo n.º 4
0
        static void ReadParamFromReg(out string logFileName, out uint maxLogBuffers)
        {
            // Read log file location from registry if exists
            string logFileNameInRegistry = null;

            RegistryConfigurationProvider wsatTraceProvider = new RegistryConfigurationProvider(RegistryHive.LocalMachine, WsatKeys.WsatRegKey, null);
            using (wsatTraceProvider)
            {
                logFileNameInRegistry = wsatTraceProvider.ReadString(WsatKeys.TraceFileDiectoryKey, null);
                maxLogBuffers = wsatTraceProvider.ReadUInt32(WsatKeys.MaxTraceBuffersKey, DefaultBuffers);

                if (maxLogBuffers == 0 || maxLogBuffers > MaxLogBuffers)
                {
                    maxLogBuffers = DefaultBuffers;
                    wsatTraceProvider.WriteUInt32(WsatKeys.MaxTraceBuffersKey, DefaultBuffers);
                }
            }

            String errLogFileName = String.Empty;
            try
            {
                if (!String.IsNullOrEmpty(logFileNameInRegistry))
                {
                    logFileNameInRegistry = logFileNameInRegistry.Trim();
                }

                if (!String.IsNullOrEmpty(logFileNameInRegistry))
                {
                    errLogFileName = logFileNameInRegistry;
                    logFileName = Path.Combine(logFileNameInRegistry, DefaultLogFileName);
                }
                else
                {
                    errLogFileName = Environment.SystemDirectory;
                    logFileName = Path.Combine(Environment.SystemDirectory, DafaultLogDirectory);
                    errLogFileName = logFileName;
                    logFileName = Path.Combine(logFileName, DefaultLogFileName);
                }
            }
            catch (ArgumentException)
            {
                throw new WsatAdminException(WsatAdminErrorCode.ETW_SESSION_INVALID_LOGFILE_NAME,
                                             SR.GetString(SR.ErrorSessionInvalidLogFileName, errLogFileName));
            }

            if (logFileName.Length >= SafeNativeMethods.MaxTraceFileNameLen)
            {
                throw new WsatAdminException(WsatAdminErrorCode.ETW_SESSION_TOO_LONG_LOGFILE_NAME,
                                             SR.GetString(SR.ErrorSessionTooLongLogFileName, logFileName));
            }
        }