diff --git a/TinyInsights.TestApp/CustomException.cs b/TinyInsights.TestApp/CustomException.cs
new file mode 100644
index 0000000..b863f0f
--- /dev/null
+++ b/TinyInsights.TestApp/CustomException.cs
@@ -0,0 +1,10 @@
+namespace TinyInsights.TestApp;
+
+public class BaseException : Exception
+{
+}
+
+
+public class CustomException : BaseException
+{
+}
diff --git a/TinyInsights.TestApp/MainPage.xaml b/TinyInsights.TestApp/MainPage.xaml
index da3f46e..5c9c2c2 100644
--- a/TinyInsights.TestApp/MainPage.xaml
+++ b/TinyInsights.TestApp/MainPage.xaml
@@ -29,9 +29,15 @@
Clicked="TrackHttpButton_OnClicked"
Text="Track http request" />
+
+
+
diff --git a/TinyInsights.TestApp/MainPage.xaml.cs b/TinyInsights.TestApp/MainPage.xaml.cs
index 19d36f7..46f2e82 100644
--- a/TinyInsights.TestApp/MainPage.xaml.cs
+++ b/TinyInsights.TestApp/MainPage.xaml.cs
@@ -88,7 +88,7 @@ private async void TrackHttpButton_OnClicked(object? sender, EventArgs e)
}
}
- private void CrashButtom_OnClicked(object? sender, EventArgs e)
+ private void CrashButton_OnClicked(object? sender, EventArgs e)
{
throw new Exception("Crash Boom Bang!");
}
@@ -102,4 +102,9 @@ private void Button_Clicked(object sender, EventArgs e)
{
Debug.WriteLine($"Memory: {GC.GetTotalMemory(true)}");
}
+
+ private void CustomCrashButton_Clicked(object sender, EventArgs e)
+ {
+ throw new CustomException();
+ }
}
\ No newline at end of file
diff --git a/TinyInsights/ApplicationInsightsProvider.cs b/TinyInsights/ApplicationInsightsProvider.cs
index 24fe4cc..15e1b13 100644
--- a/TinyInsights/ApplicationInsightsProvider.cs
+++ b/TinyInsights/ApplicationInsightsProvider.cs
@@ -154,7 +154,6 @@ private static void OnAppearing(object? sender, Page e)
client.Context.GlobalProperties.TryAdd("AppBuildNumber", AppInfo.BuildString);
client.Context.GlobalProperties.TryAdd("OperatingSystemVersion", DeviceInfo.VersionString);
- Task.Run(SendCrashes);
return client;
}
diff --git a/TinyInsights/Crash.cs b/TinyInsights/Crash.cs
index 3642619..c4ef6de 100644
--- a/TinyInsights/Crash.cs
+++ b/TinyInsights/Crash.cs
@@ -1,3 +1,5 @@
+using System.Reflection;
+
namespace TinyInsights;
public class Crash
@@ -10,33 +12,50 @@ public Crash()
public Crash(Exception exception)
{
+ var type = exception.GetType();
+
Message = exception.Message;
StackTrace = exception.StackTrace;
- ExceptionType = exception.GetType().ToString();
+ ExceptionType = type.ToString();
+ ExceptionAssembly = type.Assembly.FullName!;
Source = exception.Source;
}
- public string Message { get; init; }
+ public string? Message { get; init; }
public string? StackTrace { get; init; }
public string ExceptionType { get; init; }
+ public string ExceptionAssembly { get; init; }
public string? Source { get; init; }
public Exception? GetException()
{
- var type = Type.GetType(ExceptionType);
- if(type is null)
+ try
{
- return null;
+ Assembly assembly = Assembly.Load(ExceptionAssembly);
+ Type type = assembly.GetType(ExceptionType)!;
+
+ Exception? ex;
+
+ try
+ {
+ ex = Activator.CreateInstance(type, args: Message) as Exception;
+ }
+ catch (MissingMethodException)
+ {
+ ex = Activator.CreateInstance(type) as Exception;
+ }
+
+ if (ex is not null)
+ {
+ ex.Source = Source;
+ }
+
+ return ex;
}
-
- var ex = Activator.CreateInstance(type, args: Message) as Exception;
-
- if(ex is not null)
+ catch (Exception)
{
- ex.Source = Source;
+ return null;
}
-
- return ex;
}
}
\ No newline at end of file