@@ -90,36 +90,42 @@ public static string GetFullAssemblyName(string name)
9090
9191 private static void LoadAssemblyTable ( )
9292 {
93- var dirPath = Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) ;
94- dirPath = Path . Combine ( dirPath , "Microsoft" , "ClearScript" , Environment . Is64BitProcess ? "x64" : "x86" , GetRuntimeVersionDirectoryName ( ) ) ;
95- Directory . CreateDirectory ( dirPath ) ;
93+ // ReSharper disable EmptyGeneralCatchClause
9694
97- var filePath = Path . Combine ( dirPath , "AssemblyTable.bin" ) ;
98- if ( File . Exists ( filePath ) )
95+ string filePath = null ;
96+ try
9997 {
100- // ReSharper disable EmptyGeneralCatchClause
101-
102- try
98+ var dirPath = Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) ;
99+ if ( ! string . IsNullOrWhiteSpace ( dirPath ) )
103100 {
104- using ( var stream = new FileStream ( filePath , FileMode . Open , FileAccess . Read , FileShare . Read ) )
101+ dirPath = Path . Combine ( dirPath , "Microsoft" , "ClearScript" , Environment . Is64BitProcess ? "x64" : "x86" , GetRuntimeVersionDirectoryName ( ) ) ;
102+ Directory . CreateDirectory ( dirPath ) ;
103+
104+ filePath = Path . Combine ( dirPath , "AssemblyTable.bin" ) ;
105+ if ( File . Exists ( filePath ) )
105106 {
106- var formatter = new BinaryFormatter ( ) ;
107- table = ( ConcurrentDictionary < string , string > ) formatter . Deserialize ( stream ) ;
107+ try
108+ {
109+ using ( var stream = new FileStream ( filePath , FileMode . Open , FileAccess . Read , FileShare . Read ) )
110+ {
111+ var formatter = new BinaryFormatter ( ) ;
112+ table = ( ConcurrentDictionary < string , string > ) formatter . Deserialize ( stream ) ;
113+ }
114+ }
115+ catch ( Exception )
116+ {
117+ }
108118 }
109119 }
110- catch ( Exception )
111- {
112- }
113-
114- // ReSharper restore EmptyGeneralCatchClause
120+ }
121+ catch ( Exception )
122+ {
115123 }
116124
117125 if ( table == null )
118126 {
119- // ReSharper disable EmptyGeneralCatchClause
120-
121127 BuildAssemblyTable ( ) ;
122- if ( table != null )
128+ if ( ( table != null ) && ( filePath != null ) )
123129 {
124130 try
125131 {
@@ -133,35 +139,41 @@ private static void LoadAssemblyTable()
133139 {
134140 }
135141 }
136-
137- // ReSharper restore EmptyGeneralCatchClause
138142 }
143+
144+ // ReSharper restore EmptyGeneralCatchClause
139145 }
140146
141147 private static void BuildAssemblyTable ( )
142148 {
143- var key = Registry . LocalMachine . OpenSubKey ( "SOFTWARE\\ Microsoft\\ .NETFramework" ) ;
144- if ( key != null )
145- {
146- var dirPath = Path . Combine ( ( string ) key . GetValue ( "InstallRoot" ) , GetRuntimeVersionDirectoryName ( ) ) ;
149+ // ReSharper disable EmptyGeneralCatchClause
147150
148- table = new ConcurrentDictionary < string , string > ( ) ;
149- foreach ( var filePath in Directory . EnumerateFiles ( dirPath , "*.dll" , SearchOption . AllDirectories ) )
151+ try
152+ {
153+ var key = Registry . LocalMachine . OpenSubKey ( "SOFTWARE\\ Microsoft\\ .NETFramework" ) ;
154+ if ( key != null )
150155 {
151- // ReSharper disable EmptyGeneralCatchClause
156+ var dirPath = Path . Combine ( ( string ) key . GetValue ( "InstallRoot" ) , GetRuntimeVersionDirectoryName ( ) ) ;
152157
153- try
154- {
155- var assemblyName = Assembly . ReflectionOnlyLoadFrom ( filePath ) . GetName ( ) ;
156- table . TryAdd ( assemblyName . Name , assemblyName . FullName ) ;
157- }
158- catch ( Exception )
158+ table = new ConcurrentDictionary < string , string > ( ) ;
159+ foreach ( var filePath in Directory . EnumerateFiles ( dirPath , "*.dll" , SearchOption . AllDirectories ) )
159160 {
161+ try
162+ {
163+ var assemblyName = Assembly . ReflectionOnlyLoadFrom ( filePath ) . GetName ( ) ;
164+ table . TryAdd ( assemblyName . Name , assemblyName . FullName ) ;
165+ }
166+ catch ( Exception )
167+ {
168+ }
160169 }
161-
162- // ReSharper restore EmptyGeneralCatchClause
163170 }
164171 }
172+ catch ( Exception )
173+ {
174+ }
175+
176+ // ReSharper restore EmptyGeneralCatchClause
165177 }
166178
167179 private static string GetRuntimeVersionDirectoryName ( )
0 commit comments