private static void EnumCalendarInfoCallback(string calendarString, IntPtr context)
{
- CallbackContext callbackContext = (CallbackContext)((GCHandle)context).Target;
-
- if (callbackContext.DisallowDuplicates)
+ try
{
- foreach (string existingResult in callbackContext.Results)
+ CallbackContext callbackContext = (CallbackContext)((GCHandle)context).Target;
+
+ if (callbackContext.DisallowDuplicates)
{
- if (string.Equals(calendarString, existingResult, StringComparison.Ordinal))
+ foreach (string existingResult in callbackContext.Results)
{
- // the value is already in the results, so don't add it again
- return;
+ if (string.Equals(calendarString, existingResult, StringComparison.Ordinal))
+ {
+ // the value is already in the results, so don't add it again
+ return;
+ }
}
}
- }
- callbackContext.Results.Add(calendarString);
+ callbackContext.Results.Add(calendarString);
+ }
+ catch (Exception e)
+ {
+ Debug.Assert(false, e.ToString());
+ // we ignore the managed exceptions here because EnumCalendarInfoCallback will get called from the native code.
+ // If we don't ignore the exception here that can cause the runtime to fail fast.
+ }
}
private class CallbackContext