1
- using System ;
1
+ using System ;
2
2
using System . Collections ;
3
3
using System . Collections . Generic ;
4
4
using System . Diagnostics ;
@@ -154,11 +154,13 @@ public static void ReadFromAttributes(this ExceptionlessConfiguration config, IC
154
154
throw new ArgumentNullException ( "config" ) ;
155
155
156
156
if ( assemblies == null ) {
157
- assemblies = new List < Assembly > {
158
- #if NET45
159
- Assembly . GetCallingAssembly ( )
157
+ Assembly callingAssembly = null ;
158
+ #if NET45 || NETSTANDARD2_0
159
+ try {
160
+ callingAssembly = Assembly . GetCallingAssembly ( ) ;
161
+ } catch ( PlatformNotSupportedException ) { }
160
162
#endif
161
- } ;
163
+ assemblies = new List < Assembly > { callingAssembly } ;
162
164
}
163
165
164
166
assemblies = assemblies . Where ( a => a != null ) . Distinct ( ) . ToList ( ) ;
@@ -182,7 +184,7 @@ public static void ReadFromAttributes(this ExceptionlessConfiguration config, IC
182
184
183
185
foreach ( var assembly in assemblies ) {
184
186
var attributes = assembly . GetCustomAttributes ( typeof ( ExceptionlessSettingAttribute ) ) ;
185
- foreach ( ExceptionlessSettingAttribute attribute in attributes . OfType < ExceptionlessSettingAttribute > ( ) ) {
187
+ foreach ( var attribute in attributes . OfType < ExceptionlessSettingAttribute > ( ) ) {
186
188
if ( ! String . IsNullOrEmpty ( attribute . Name ) )
187
189
config . Settings [ attribute . Name ] = attribute . Value ;
188
190
}
@@ -258,13 +260,10 @@ public static void ReadAllConfig(this ExceptionlessConfiguration config, params
258
260
#if NETSTANDARD1_5
259
261
config . ReadFromAttributes ( Assembly . GetEntryAssembly ( ) ) ;
260
262
#elif NET45 || NETSTANDARD2_0
261
- Assembly callingAssembly ;
263
+ Assembly callingAssembly = null ;
262
264
try {
263
265
callingAssembly = Assembly . GetCallingAssembly ( ) ;
264
- }
265
- catch ( PlatformNotSupportedException ) {
266
- callingAssembly = null ;
267
- }
266
+ } catch ( PlatformNotSupportedException ) { }
268
267
269
268
config . ReadFromAttributes ( Assembly . GetEntryAssembly ( ) , callingAssembly ) ;
270
269
#endif
0 commit comments