Skip to content

Commit 2629566

Browse files
committed
Fixed an issue that would cause a runtime exception with UWP applications.
1 parent 9cf6aea commit 2629566

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

Source/Shared/Extensions/ExceptionlessConfigurationExtensions.cs

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -158,29 +158,34 @@ public static void ReadFromAttributes(this ExceptionlessConfiguration config, IC
158158

159159
assemblies = assemblies.Where(a => a != null).Distinct().ToList();
160160

161-
foreach (var assembly in assemblies) {
162-
object[] attributes = assembly.GetCustomAttributes(typeof(ExceptionlessAttribute), false);
163-
if (attributes.Length <= 0 || !(attributes[0] is ExceptionlessAttribute))
164-
continue;
165-
166-
var attr = attributes[0] as ExceptionlessAttribute;
167-
168-
config.Enabled = attr.Enabled;
169-
170-
if (!String.IsNullOrEmpty(attr.ApiKey) && attr.ApiKey != "API_KEY_HERE")
171-
config.ApiKey = attr.ApiKey;
172-
if (!String.IsNullOrEmpty(attr.ServerUrl))
173-
config.ServerUrl = attr.ServerUrl;
174-
175-
break;
176-
}
161+
try {
162+
foreach (var assembly in assemblies) {
163+
object[] attributes = assembly.GetCustomAttributes(typeof(ExceptionlessAttribute), false);
164+
if (attributes.Length <= 0 || !(attributes[0] is ExceptionlessAttribute))
165+
continue;
166+
167+
var attr = attributes[0] as ExceptionlessAttribute;
168+
169+
config.Enabled = attr.Enabled;
170+
171+
if (!String.IsNullOrEmpty(attr.ApiKey) && attr.ApiKey != "API_KEY_HERE")
172+
config.ApiKey = attr.ApiKey;
173+
if (!String.IsNullOrEmpty(attr.ServerUrl))
174+
config.ServerUrl = attr.ServerUrl;
175+
176+
break;
177+
}
177178

178-
foreach (var assembly in assemblies) {
179-
object[] attributes = assembly.GetCustomAttributes(typeof(ExceptionlessSettingAttribute), false);
180-
foreach (ExceptionlessSettingAttribute attribute in attributes.OfType<ExceptionlessSettingAttribute>()) {
181-
if (!String.IsNullOrEmpty(attribute.Name))
182-
config.Settings[attribute.Name] = attribute.Value;
179+
foreach (var assembly in assemblies) {
180+
object[] attributes = assembly.GetCustomAttributes(typeof(ExceptionlessSettingAttribute), false);
181+
foreach (ExceptionlessSettingAttribute attribute in attributes.OfType<ExceptionlessSettingAttribute>()) {
182+
if (!String.IsNullOrEmpty(attribute.Name))
183+
config.Settings[attribute.Name] = attribute.Value;
184+
}
183185
}
186+
} catch (Exception ex) {
187+
var log = config.Resolver.GetLog();
188+
log.Error(ex, "Error while reading attribute configuration. Please contact support for more information.");
184189
}
185190
}
186191
}

0 commit comments

Comments
 (0)