I'm writing a .NET application that is an "add-in" to the Autodesk Revit program. I want to use Sentry in order to log and view unhandled exceptions in general. From my understanding, the following code should capture an exception and send it to my dashboard on my sentry.io account.
using (SentrySdk.Init("<my sentry dsn string>"))
{
throw new DuplicateWaitObjectException();
}
However, no DuplicateWaitObjectException shows up on my dashboard. I'm at a loss for why the above code doesn't work, especially since capturing an error explicitly works fine:
SentrySdk.Init("<my sentry dsn string>");
try
{
throw new DuplicateWaitObjectException();
}
catch (Exception err)
{
SentrySdk.CaptureException(err);
}
I suspect it may have something to do with my application being an add-in which is loaded by the Revit program, instead of being a stand-alone application, but I'm really not sure. Am I correct in believing that my code (the first block) should work?
I'm thinking of mitigating this problem instead wrapping my code in a try-catch block at the Revit entry-point, but that seems rather hacky to me, seeing as that I don't know what's causing this problem.
I'm working in Visual Studio 2019 for Windows (10) and developing for Revit 2019. My SentrySDK version is v2.1.1.
Thanks for reading
Revit captures any unhandled exceptions, so that library won't be able to see them.
Your idea of wrapping the code in a try-catch block is by far the easiest solution.
The only other alternative is to run code in a separate AppDomain or process, and use something like remoting or gRPC to communicate with the Revit API.