@@ -62,8 +62,10 @@ static ConfuserEngine() {
6262 /// <paramref name="parameters" />.Project is <c>null</c>.
6363 /// </exception>
6464 public static Task Run ( ConfuserParameters parameters , CancellationToken ? token = null ) {
65+ if ( parameters == null )
66+ throw new ArgumentNullException ( nameof ( parameters ) ) ;
6567 if ( parameters . Project == null )
66- throw new ArgumentNullException ( " parameters" ) ;
68+ throw new ArgumentNullException ( nameof ( parameters ) ) ;
6769 if ( token == null )
6870 token = new CancellationTokenSource ( ) . Token ;
6971 return Task . Factory . StartNew ( ( ) => RunInternal ( parameters , token . Value ) , token . Value ) ;
@@ -136,7 +138,7 @@ static void RunInternal(ConfuserParameters parameters, CancellationToken token)
136138
137139 // 4. Load modules
138140 context . Logger . Info ( "Loading input modules..." ) ;
139- marker . Initalize ( prots , packers ) ;
141+ marker . Initialize ( prots , packers ) ;
140142 MarkerResult markings = marker . MarkProject ( context . Project , context ) ;
141143 context . Modules = new ModuleSorter ( markings . Modules ) . Sort ( ) . ToList ( ) . AsReadOnly ( ) ;
142144 foreach ( var module in context . Modules )
@@ -156,7 +158,7 @@ static void RunInternal(ConfuserParameters parameters, CancellationToken token)
156158 comp . Initialize ( context ) ;
157159 }
158160 catch ( Exception ex ) {
159- context . Logger . ErrorException ( "Error occured during initialization of '" + comp . Name + "'." , ex ) ;
161+ context . Logger . ErrorException ( "Error occurred during initialization of '" + comp . Name + "'." , ex ) ;
160162 throw new ConfuserException ( ex ) ;
161163 }
162164 context . CheckCancellation ( ) ;
@@ -478,31 +480,36 @@ static IEnumerable<string> GetFrameworkVersions() {
478480 using ( RegistryKey ndpKey =
479481 RegistryKey . OpenRemoteBaseKey ( RegistryHive . LocalMachine , "" ) .
480482 OpenSubKey ( @"SOFTWARE\Microsoft\NET Framework Setup\NDP\" ) ) {
483+ if ( ndpKey == null ) yield break ;
481484 foreach ( string versionKeyName in ndpKey . GetSubKeyNames ( ) ) {
482485 if ( ! versionKeyName . StartsWith ( "v" ) )
483486 continue ;
484487
485- RegistryKey versionKey = ndpKey . OpenSubKey ( versionKeyName ) ;
486- var name = ( string ) versionKey . GetValue ( "Version" , "" ) ;
487- string sp = versionKey . GetValue ( "SP" , "" ) . ToString ( ) ;
488- string install = versionKey . GetValue ( "Install" , "" ) . ToString ( ) ;
489- if ( install == "" || sp != "" && install == "1" )
490- yield return versionKeyName + " " + name ;
491-
492- if ( name != "" )
493- continue ;
488+ using ( RegistryKey versionKey = ndpKey . OpenSubKey ( versionKeyName ) ) {
489+ if ( versionKey == null ) continue ;
490+ var name = ( string ) versionKey . GetValue ( "Version" , "" ) ;
491+ string sp = versionKey . GetValue ( "SP" , "" ) . ToString ( ) ;
492+ string install = versionKey . GetValue ( "Install" , "" ) . ToString ( ) ;
493+ if ( install == "" || sp != "" && install == "1" )
494+ yield return versionKeyName + " " + name ;
494495
495- foreach ( string subKeyName in versionKey . GetSubKeyNames ( ) ) {
496- RegistryKey subKey = versionKey . OpenSubKey ( subKeyName ) ;
497- name = ( string ) subKey . GetValue ( "Version" , "" ) ;
498496 if ( name != "" )
499- sp = subKey . GetValue ( "SP" , "" ) . ToString ( ) ;
500- install = subKey . GetValue ( "Install" , "" ) . ToString ( ) ;
501-
502- if ( install == "" )
503- yield return versionKeyName + " " + name ;
504- else if ( install == "1" )
505- yield return " " + subKeyName + " " + name ;
497+ continue ;
498+
499+ foreach ( string subKeyName in versionKey . GetSubKeyNames ( ) ) {
500+ using ( RegistryKey subKey = versionKey . OpenSubKey ( subKeyName ) ) {
501+ if ( subKey == null ) continue ;
502+ name = ( string ) subKey . GetValue ( "Version" , "" ) ;
503+ if ( name != "" )
504+ sp = subKey . GetValue ( "SP" , "" ) . ToString ( ) ;
505+ install = subKey . GetValue ( "Install" , "" ) . ToString ( ) ;
506+
507+ if ( install == "" )
508+ yield return versionKeyName + " " + name ;
509+ else if ( install == "1" )
510+ yield return " " + subKeyName + " " + name ;
511+ }
512+ }
506513 }
507514 }
508515 }
0 commit comments