Ejemplo n.º 1
0
        internal static void SaveMaxTraceFileSizeToReg(uint fileSize)
        {
            RegistryConfigurationProvider wsatTraceProvider = new RegistryConfigurationProvider(RegistryHive.LocalMachine, WsatKeys.WsatRegKey, null);

            using (wsatTraceProvider)
            {
                wsatTraceProvider.WriteUInt32(WsatKeys.MaxTraceSizeKey, fileSize);
            }
        }
Ejemplo n.º 2
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.º 3
0
        // For UI to get MaxFileSize saved in registry
        internal static uint GetMaxTraceFileSizeFromReg()
        {
            uint fileSize = 0;

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

            using (wsatTraceProvider)
            {
                fileSize = wsatTraceProvider.ReadUInt32(WsatKeys.MaxTraceSizeKey, DefaultLogFileSize);
            }

            return(fileSize);
        }
Ejemplo n.º 4
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.º 5
0
        public static void RegisterWithMmc(Type type)
        {
            try
            {
                RegistryConfigurationProvider provider = new RegistryConfigurationProvider(RegistryHive.LocalMachine, WsatKeys.WSATRegisterSnapinWsatPropertySheetKey, null);

                using (provider)
                {
                    provider.WriteString(WsatKeys.WSATRegisterSnapinWsatPropertySheetAboutEntry, WsatKeys.WSATRegisterSnapinWsatPropertySheetAboutValue);
                    provider.WriteString(WsatKeys.WSATRegisterSnapinWsatPropertySheetNameEntry, WsatKeys.WSATRegisterSnapinWsatPropertySheetNameValue);
                }

                provider = new RegistryConfigurationProvider(RegistryHive.LocalMachine, WsatKeys.WSATRegisterNodeTypesCompServCompNodeKey, null);
                using (provider)
                {
                    provider.WriteString(WsatKeys.WSATRegisterNodeTypesWsatPropertySheetGUIDEntry, WsatKeys.WSATRegisterNodeTypesWsatPropertySheetGUIDValue);
                }

                // put binary path
                string assemblyLocation = System.Reflection.Assembly.GetExecutingAssembly().Location;
                provider = new RegistryConfigurationProvider(RegistryHive.LocalMachine, WsatKeys.WsatRegKey, null);
                using (provider)
                {
                    provider.WriteString(WsatKeys.WSATAssemblyPathEntry, assemblyLocation);
                }
            }
#pragma warning suppress 56500
            catch (Exception ex)
            {
                if (Utilities.IsCriticalException(ex))
                {
                    throw;
                }

                ShowErrorDialog(ex.Message);
            }
        }
Ejemplo n.º 6
0
        public static void RegisterWithMmc(Type type)
        {
            try
            {
                RegistryConfigurationProvider provider = new RegistryConfigurationProvider(RegistryHive.LocalMachine, WsatKeys.WSATRegisterSnapinWsatPropertySheetKey, null);

                using (provider)
                {
                    provider.WriteString(WsatKeys.WSATRegisterSnapinWsatPropertySheetAboutEntry, WsatKeys.WSATRegisterSnapinWsatPropertySheetAboutValue);
                    provider.WriteString(WsatKeys.WSATRegisterSnapinWsatPropertySheetNameEntry, WsatKeys.WSATRegisterSnapinWsatPropertySheetNameValue);
                }

                provider = new RegistryConfigurationProvider(RegistryHive.LocalMachine, WsatKeys.WSATRegisterNodeTypesCompServCompNodeKey, null);
                using (provider)
                {
                    provider.WriteString(WsatKeys.WSATRegisterNodeTypesWsatPropertySheetGUIDEntry, WsatKeys.WSATRegisterNodeTypesWsatPropertySheetGUIDValue);
                }

                // put binary path
                string assemblyLocation = System.Reflection.Assembly.GetExecutingAssembly().Location;
                provider = new RegistryConfigurationProvider(RegistryHive.LocalMachine, WsatKeys.WsatRegKey, null);
                using (provider)
                {
                    provider.WriteString(WsatKeys.WSATAssemblyPathEntry, assemblyLocation);
                }
            }
#pragma warning suppress 56500
            catch (Exception ex)
            {
                if (Utilities.IsCriticalException(ex))
                {
                    throw;
                }

                ShowErrorDialog(ex.Message);
            }
        }
Ejemplo n.º 7
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.º 8
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.º 9
0
 internal static void SaveMaxTraceFileSizeToReg(uint fileSize)
 {
     RegistryConfigurationProvider wsatTraceProvider = new RegistryConfigurationProvider(RegistryHive.LocalMachine, WsatKeys.WsatRegKey, null);
     using (wsatTraceProvider)
     {
         wsatTraceProvider.WriteUInt32(WsatKeys.MaxTraceSizeKey, fileSize);
     }
 }
Ejemplo n.º 10
0
        // For UI to get MaxFileSize saved in registry
        internal static uint GetMaxTraceFileSizeFromReg()
        {
            uint fileSize = 0;

            RegistryConfigurationProvider wsatTraceProvider = new RegistryConfigurationProvider(RegistryHive.LocalMachine, WsatKeys.WsatRegKey, null);
            using (wsatTraceProvider)
            {
                fileSize = wsatTraceProvider.ReadUInt32(WsatKeys.MaxTraceSizeKey, DefaultLogFileSize);
            }

            return fileSize;
        }