protected override bool TryGetExternalDefault(string section, string property, out string value) { value = null; #if NETFRAMEWORK // Check for machine (HKLM) registry keys that match the Git configuration name. // These can be set by system administrators via Group Policy, so make useful defaults. using (Win32.RegistryKey configKey = Win32.Registry.LocalMachine.OpenSubKey(Constants.WindowsRegistry.HKConfigurationPath)) { if (configKey is null) { // No configuration key exists return(false); } string name = $"{section}.{property}"; object registryValue = configKey.GetValue(name); if (registryValue is null) { // No property exists return(false); } value = registryValue.ToString(); _trace.WriteLine($"Default setting found in registry: {name}={value}"); return(true); } #else return(base.TryGetExternalDefault(section, property, out value)); #endif }
/// <include file='doc\ConnectionManager.uex' path='docs/doc[@for="Manager.Manager"]/*' /> public Manager() { ManagerFactory factory = null; // ENABLING THIS FOR RELEASE BUILDS FOR NOW SO THAT DEBUGGING WILL WORK FOR RELEASE BUILDS // THIS SHOULD BE REVISITED FOR FUTURE RELEAsES //#if DEBUG if (NoConnectionManagerHost) { factory = new ManagerFactory(); Initialize(factory); return; } //#endif RegisterChannel(); // // Launch the ConnectionManagerHost if possible // bool fLaunch = true; factory = (ManagerFactory)Activator.GetObject(typeof(ManagerFactory), string.Format("{0}://{1}/{2}", ChannelRegistrationHelper.c_ChannelName, ManagerFactory.Port, ManagerFactory.ServiceName)); for (int iRetries = 0; iRetries < 20; iRetries++) { if (Initialize(factory)) { break; } if (fLaunch) { string file = null; using (Win32.RegistryKey key = Win32.Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\.NETTinyFramework")) { file = (string)key.GetValue("ConnectionManager"); } System.Diagnostics.Process process = new Process(); process.StartInfo = new ProcessStartInfo(file); process.StartInfo.CreateNoWindow = true; process.StartInfo.UseShellExecute = false; process.Start(); fLaunch = false; } Thread.Sleep(100); } if (m_mgr == null) { throw new ApplicationException("Could not create ManagerRemote"); } }
/// <summary> /// Gets the Location of devenv.exe based on the RegistryRoot for the current package type /// </summary> private string getVSInstallDir(RegistrationContext context) { DefaultRegistryRootAttribute regRootAttr = (DefaultRegistryRootAttribute)TypeDescriptor.GetAttributes(context.ComponentType)[typeof(DefaultRegistryRootAttribute)]; if (regRootAttr == null) { throw new NotSupportedException("could not find DefaultRegitryRootAttribute on " + context.ComponentType.ToString()); } Win32.RegistryKey key = Win32.Registry.LocalMachine.OpenSubKey(regRootAttr.Root); //We are using HKCU in the case that the HKLM Experimental hive doesn't exist if (key == null || key.GetValue("InstallDir") == null) { key = Win32.Registry.CurrentUser.OpenSubKey(regRootAttr.Root + @"\Configuration"); } string vsInstallDir = (string)key.GetValue("InstallDir"); key.Close(); return(vsInstallDir); }
public static void InitSLApi() { // check if already initialized if (true == m_bSLApiInit) { return; } // we must check if debug pack is installed Win32.RegistryKey netFrameworkKey = null; IntPtr procAddr = IntPtr.Zero; try { netFrameworkKey = Win32.Registry.LocalMachine.OpenSubKey( m_strNetFramework, false); if (null == netFrameworkKey) { throw new System.Exception("Unable to open the .NET Registry key: HKLM\\" + m_strNetFramework); } m_strDbgPackShimPath = (string)netFrameworkKey.GetValue( m_strValDbgPackShimPath, null, RegistryValueOptions.DoNotExpandEnvironmentNames); if (null == m_strDbgPackShimPath) { throw new System.Exception("Unable to open up the DbgPackShimPath registry key: HKLM\\" + m_strNetFramework + "\\" + m_strDbgPackShimPath); } // now initializing all the func ptrs m_hndModuleMscoree = LoadLib(m_strDbgPackShimPath); procAddr = GetProcAddr(m_hndModuleMscoree, "CreateDebuggingInterfaceFromVersion"); if (IntPtr.Zero == procAddr) { throw new Exception("Failed to get address of dbgshim!CreateDebuggingInterfaceFromVersion"); } else { m_CreateDebuggingInterfaceFromVersion = (delgCreateDebuggingInterfaceFromVersion)Marshal.GetDelegateForFunctionPointer( procAddr, typeof(delgCreateDebuggingInterfaceFromVersion)); } try { procAddr = GetProcAddr(m_hndModuleMscoree, "CreateDebuggingInterfaceFromVersionEx"); } catch (Win32Exception) { procAddr = IntPtr.Zero; } if (IntPtr.Zero == procAddr) { m_CreateDebuggingInterfaceFromVersionEx = null; Console.WriteLine("This Silverlight/CoreCLR version doesn't have CDIFVex"); } else { m_CreateDebuggingInterfaceFromVersionEx = (delgCreateDebuggingInterfaceFromVersionEx)Marshal.GetDelegateForFunctionPointer( procAddr, typeof(delgCreateDebuggingInterfaceFromVersionEx)); } procAddr = GetProcAddr(m_hndModuleMscoree, "CreateVersionStringFromModule"); if (IntPtr.Zero == procAddr) { throw new Exception("Failed to get address of dbgshim!CreateVersionStringFromModule"); } else { m_CreateVersionStringFromModule = (delgCreateVersionStringFromModule)Marshal.GetDelegateForFunctionPointer( procAddr, typeof(delgCreateVersionStringFromModule)); } procAddr = GetProcAddr(m_hndModuleMscoree, "EnumerateCLRs"); if (IntPtr.Zero == procAddr) { throw new Exception("Failed to get address of dbgshim!EnumerateCLRs"); } else { m_EnumerateCLRs = (delgEnumerateCLRs)Marshal.GetDelegateForFunctionPointer( procAddr, typeof(delgEnumerateCLRs)); } procAddr = GetProcAddr(m_hndModuleMscoree, "CloseCLREnumeration"); if (IntPtr.Zero == procAddr) { throw new Exception("Failed to get address of dbgshim!CloseCLREnumeration"); } else { m_CloseCLREnumeration = (delgCloseCLREnumeration)Marshal.GetDelegateForFunctionPointer( procAddr, typeof(delgCloseCLREnumeration)); } procAddr = GetProcAddr(m_hndModuleMscoree, "GetStartupNotificationEvent"); if (IntPtr.Zero == procAddr) { throw new Exception("Failed to get address of dbgshim!GetStartupNotificationEvent"); } else { m_GetStartupNotificationEvent = (delgGetStartupNotificationEvent)Marshal.GetDelegateForFunctionPointer( procAddr, typeof(delgGetStartupNotificationEvent)); } // We are done initializing m_bSLApiInit = true; } finally { if (null != netFrameworkKey) { netFrameworkKey.Close(); } // we will keep the cached handle to loaded mscoree.dll // around for a while.......... } }