Hello again ;-)
Still working on the VSTA integration V1.0 (are there any news about release date for v2.0?) into our software. I got a new issue:
I'm using more than one addin to enhance the application. The addins are loaded and unloaded during runtime of the application, depending on the data the end user works on. This works perfekt. The user is able to debug the addins loaded from the VSTA IDE. Therefore for each addin there is an object instance of a management class, managing the adin an the event calling inside the addin. Each instance calls
m_HostDebugUri = ExternalDebugging.RegisterExternalDebugHost(this);
to register itself for the debugging. This class implements the OnDebugStarting() event and is called from the VSTA framework when debugging starts and loads the addin into the debug context. The instances of the management class write the information which addin they manage and the m_HostDebugUri to a table, so when the user starts debugging inside the VSTA IDE, the corresponding HostDebugUri is set in the VSTA IDE via a hook in the Command handler for the debugging command. So the user is even able to debug more than one addin parallel using more than one VSTA IDE. This works also perfekt, I'm able to debug more than one addin in parallel.
The problem is the following, everything works well up to the pojnt when the first addin is unloaded and the management class calls
ExternalDebugging.UnregisterExternalDebugHost(m_HostDebugUri);
After that step the debugging does not work anymore for the remaining addins and also for new loaded addins which are registering a new ExternalDebugHost. The OnDebugStarting() event is correctly called from the VSTA framework but when one tries to load the addin into the debug context the error "System.Reflection.TargetInvocationException: System.Reflection.TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht. ---> System.Reflection.TargetInvocationException: System.Reflection.TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht. ---> System.Runtime.Remoting.RemotingException: The requested object is not registered in the running object table." occurs.
When I remove the ExternalDebugging.UnregisterExternalDebugHost(m_HostDebugUri); calls from the addin unload code everything continues to work correct but with the ROT-Viewer I can see that the number of VSTA entries in the ROT table grow and grow with each addin loaded and unloaded. When the application is closed, all entries in the ROT table are removed but I don't have a good feeling about filling the ROT table with an unlimited number VSTA entries until program termination.
Do you have any idea how to unregister an ExternalDebugHost from a process without stopping the debugging to work for other addins in the same process?