public static string GetAppropriateBitnessModuleModulePath(bool is64bit, RuntimeVersions runtimeVersion)
 {
     if (RuntimeVersions.V40 == runtimeVersion)
     {
         // Retrieve the regkey with Read permission. Note that on Windows 8 and later, only Trusted installer has write access to this key.
         using (RegistryHandle regKey = RegistryHandle.GetCorrectBitnessHKLMSubkey(is64bit, ServiceModelInstallStrings.WinFXRegistryKey, false))
         {
             return(regKey.GetStringValue(ServiceModelInstallStrings.RuntimeInstallPathName).TrimEnd('\0') + "\\" + fileName);
         }
     }
     else
     {
         // Try to find the 3.0 version
         RegistryHandle regkey = null;
         try
         {
             if (SafeNativeMethods.ERROR_SUCCESS == RegistryHandle.TryGetCorrectBitnessHKLMSubkey(is64bit, Wcf30RegistryKey, out regkey))
             {
                 return(regkey.GetStringValue(Runtime30InstallPathName).TrimEnd('\0') + "\\" + fileName);
             }
             else
             {
                 //We don't want to automatically roll forward to 4.0, so we throw an exception if we can't find the 3.0 reg key
                 throw Tool.CreateException(SR.GetString(SR.FailedToGetRegistryKey, Wcf30RegistryKey, "3.0"), null);
             }
         }
         finally
         {
             if (regkey != null)
             {
                 regkey.Dispose();
             }
         }
     }
 }