The Editor Factory implementations, in MPF based VS SDK editor sample and wizard generated code, improperly construct the ServiceProvider members. This causes calls to GetService to give back unexpected results. For e.g if you ask for SVsFrameWindow service it will always return the last created frame, instead of the frame each window pane is sited on.

The IVsEditorFactory.SetSite implementations all look something like the following:

        public int SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider psp)
        {
            vsServiceProvider = new ServiceProvider(psp);
            return VSConstants.S_OK;
        }

this should instead be

        public int SetSite(Microsoft.VisualStudio.OLE.Interop.IServiceProvider psp)
        {
            vsServiceProvider = new ServiceProvider(psp, false);
            return VSConstants.S_OK;
        }

It is important to pass false for the "defaultServices" parameter here. If you don't do this then the GetService implentation of your WindowPane derived class will not function properly. This _vsServiceProvider is passed as the parentProvider when creating the WindowPane derived object. If you pass false, then WindowPane.GetService will not return the IVsWindowFrame contextual services (e.g. SVsWindowFrame, STrackSelection, SVsUndoManager) correctly for each instance of the WindowPane class.

Note, that the VS SDK editor samples have this problem, as does the VS SDK Package Wizard. The VS SDK team intends to fix the samples and wizard templates in upcoming releases.

Hope that helps

Regards

Dr. eX