Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello anyone,

I run in a confusing problem.

Within my Editor's pane of my custom VisualStudio Package I am getting following error message:
Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.VisualStudio.Shell.Interop.ITrackSelection'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{6D5140C5-7436-11CE-8034-00AA006009FA}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).


The locals are:
+ (ISelectionContainer)selContainer {Microsoft.VisualStudio.Shell.SelectionContainer} Microsoft.VisualStudio.Shell.Interop.ISelectionContainer {Microsoft.VisualStudio.Shell.SelectionContainer}


+selContainer {Microsoft.VisualStudio.Shell.SelectionContainer} Microsoft.VisualStudio.Shell.SelectionContainer

-track COM Object Microsoft.VisualStudio.Shell.Interop.ITrackSelection {System.__ComObject}



The caller code follows, actualy this code part can be found on the web several times, I just copied and pasted it:
C#
private ITrackSelection TrackSelection {
   get {
       if (trackSel == null)
           trackSel = GetService(typeof(STrackSelection)) as ITrackSelection;
       return trackSel;
   }
}

public void UpdateSelection()
{
    ITrackSelection track = TrackSelection;
    if (track != null)
        track.OnSelectChange((ISelectionContainer)selContainer);
}


The most confusing point is, that within my constructor everything works fine! The interface can be queried and has been excuted, but any following call fails.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900