We have a bunch of forms written in C# as ArcMap commands, which are running happily in the normal way from command buttons. The forms interact with the map by creating layers and symbologies, and by listening for selections on the layers to update their own display.
For a number of annoying reasons, we now have to convert these to run from an external executable, but still interact with ArcMap. I'm attempting to use the approach of ArcMap "automation" so the forms are created by the executable, which also creates an ArcMap instance and passes it to the forms to allow them to interact.
I've got past the process-space issues of not being able to use "new" instantiation in the form's code for ArcObjects (layers, etc) that ArcMap has to interact with, and using IObjectFactory to get ArcMap to create them for me instead.
But I am struggling with events. The form needs to listen to events like SelectionChanged in the map and update itself. If I create an event handler in the normal way like
dSelChangedE = new IActiveViewEvents_SelectionChangedEventHandler(OnSelectionChanged);
m_pMap.SelectionChanged += dSelChangedE;
Then my OnSelectionChanged event method in the form fires correctly, but ArcMap seems to miss the event itself (even when it was ArcMap that created it, e.g. by interactive feature selection): the selection isn't displayed on screen! I guess this is process-space issues again but I don't know how to get around them. I can't see any way to make IObjectFactory make the event handler, for instance.
This thread on the old ESRI forums is similar the problem I'm having http://forums.esri.com/Thread.asp?c=93&f=993&t=213577 but in my case it's the other way around: I can get my controlling application to listen to the events, but then Arcmap loses track of them.