Catching Exceptions in external assemblies

OK, so I’ve got a .NET assembly that interfaces with some RFID hardware that I’m trying to integrate into a Unity project. It actually works fine (mostly) in a compiled project, however in the editor I have a problem. Something in the assembly throws a NULL exception when I hit the Stop button in the editor.

The assembly creates an object that can connect to the RFID stuff, and it appears to do so successfully, however something in the assembly code produces the NULL on Stop, so I don’t know if it’s creating a separate thread in the object’s constructor or what, but it makes testing in the editor impossible.

Does anyone have any tips to help track down the source of the problem? I haven’t done any work with external assemblies before.

Thanks!

I think MonoBehavior has a Shutdown event that you should use to cleanly abort your threads in the external assembly.

Well, there is OnApplicationQuit, but I’m not sure how to find out if there are any threads or other objects that need cleaning. I’m not starting any new threads myself.