I am developing a C# add-in for Solidworks. I am debugging it from Visual Studio 2017. The .dll is registered properly, and everything works as it should. For debugging purposes, I set VS2017 to launch Solidworks after re-compiling .dll (Start External Program).
Now, if I set any method to run during the initialization of my add-in in the Solidworks, and it encounters an unhandled exception, I am returned back to the IDE with the exception printed out at the corresponding line of code, so I can debug and fix it, just like it should. However, if an exception occurs AFTER the add-in and Solidworks are loaded, Solidworks closes silently, and the debugging session in VS2017 ends. In other words, no unhandled exception message, no indication to what caused it.
I confirmed this by intentionally creating a method that should cause an unhandled exception (division by zero). If I call this method anywhere during the initialization of the add-in, it am returned back to my IDE with exception info being printed out. If I call this method anytime later (say, pressing button in the UI or on timer), debugging session ends silently and Solidworks closes.
I am not entirely sure if this is a Solidworks thing, or maybe Visual Studio IDE thing, but I hope that someone might have encountered a similar issue, and could suggest what to do.
I am not posting any code because I'm not sure what could be relevant here, but if you need anything to diagnose the problem, just let me know and I'll provide it.