1

I'm developing an application that is extensible throught plugin. When a plugin instance is needed i'm creating it using the Activator.CreateInstance.

In the code below pluginInst is an instance of a test plugin created with Activator.CreateInstance and testException() is a plugin function that now simply throw an exception.

Try
    pluginInst.testException()
Catch ex As Exception
    Console.WriteLine("plugin exception generated")
End Try

The message never appears in the output window of visual studio, and if i put a breakpoint in the catch it never goes there. The plugin instance crash but the main application keep running normally. The only thing that i see is this message on visual studio output window

Eccezione generata: 'System.Exception' in testPlugin.dll

How i can handle plugin exceptions like this in main application? What i'm doing wrong?

Luca R
  • 11
  • 1

1 Answers1

0

i've solved my problem. As reported here

the SystemEvents class fires the event on the wrong thread. Which is caused by an initialization problem in your program. The typical trigger is not creating the first window on the main thread, that confuzzles SystemEvents. It tries to fire an event on that same thread again but it isn't around anymore.

In my case the exception was generated from a plugin initialization called in the form load event of the main application form. In this phase the correct thread for the unhandled exceptions seems to have not yet been created, so exceptions simply goes nowhere. You can see in this case that if you close the application it is still running, in my case an hanged thread of type fpushmessageloop (the one wich generates the exception) was preventing the shutdown of the application.

In my case move the plugin inizialization to the shown event of the application main form was enough to solve the problem.

Luca R
  • 11
  • 1