locked
Opening editors in a VSPackage using IVsUIShellOpenDocument.OpenSpecificEditor has changed? RRS feed

  • Question

  • Hi!

    I'm prototyping the implemention of my company's VSPackage from VS2008 into VS2010, and I've been following the msdn guide on upgrading VSP's. My package fails when I open an editor in VS2010, but works fine in VS2008, and I've identified why. When the explorer window item is clicked to open its editor, a call is made to IVsUIShellOpenDocument.OpenSpecificEditor(), the last parameter of which is referenced "out" and contains the IVsWindowFrame object.

    In VS2008, this works fine, and when we call the IVsWindowFrame's Show() method at some point our HierarchyNode implementation's public int GetProperty(uint itemid, int propid, out object result) is called, some options of which use the IVsWindowFrame object to retrieve the OwnerCaption i.e. "IVsWindowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_OwnerCaption, out o);"

    In VS2010 the problem comes in that GetProperty() is called within the IVsUIShellOpenDocument.OpenSpecificEditor() call but before the last parameter (the IVsWindowFrame) is populated, in short the request for these properties is coming in _before_ the frame object is passed back or the call to OpenSpecificEditor() returns, but I need the frame object to satisfy some of the property requests.

    Can anyone advise a workaround? I tried passing in a variable that is accessable to the HierarchyNode as the last parameter for OpenSpecificEditor, but this variable is still null when the property is requested.
    Tuesday, January 26, 2010 4:50 PM

Answers

  • Hi,

    Could you please clarify why you need the frame object to return hierarchy properties for the node associated with that frame?

    The frame is owned by the shell and its properties are based on the properties of the document/hierarchy node associated with it.

    The OwnerCaption and EditorCaption are exactly as the name says, frame properties that are provided by the owner hierarhcy or the editor and consumed by the shell, not the other way around…

     

    Per http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.__vsfpropid.aspx

    VSFPROPID_OwnerCaption

    BSTR. Portion of caption defined by owning IVsHierarchy

    so the hierarchy should already have this value, to begin with…


    Dmitry.
     

    • Marked as answer by Neilhza Thursday, January 28, 2010 2:41 PM
    Wednesday, January 27, 2010 9:30 PM

All replies

  • Hi,

    Could you please clarify why you need the frame object to return hierarchy properties for the node associated with that frame?

    The frame is owned by the shell and its properties are based on the properties of the document/hierarchy node associated with it.

    The OwnerCaption and EditorCaption are exactly as the name says, frame properties that are provided by the owner hierarhcy or the editor and consumed by the shell, not the other way around…

     

    Per http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.__vsfpropid.aspx

    VSFPROPID_OwnerCaption

    BSTR. Portion of caption defined by owning IVsHierarchy

    so the hierarchy should already have this value, to begin with…


    Dmitry.
     

    • Marked as answer by Neilhza Thursday, January 28, 2010 2:41 PM
    Wednesday, January 27, 2010 9:30 PM
  • Hi Dmitry

    Thank you for your response. I apologise for the noob question, I'm not very experienced in creating editors for VSP's and doing some maintenance on a package implemented by a colleague who has left. I've taken your advice and used the value that's passed from the hierarchy, thanks for that! I can see the editor opening in VS2010, but after it has displayed for maybe half a second, the following exception is thrown by Visual Studio and crashes everything, below here is the exception detail.

    The inner exception is "Specified cast is not valid." Sometimes the debugger reports that a Guid format is invalid, so it looks like Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.UpdateDocumentIcon() is trying to cast an invalid value as a guid. Do you know where the DocumentIcon is set? The exception is being thrown after my code has exited, so I can't see exactly what I'm doing wrong. My apologies if this is also a stupid question, I am still learning :)

    System.Reflection.TargetInvocationException was unhandled
      Message=Exception has been thrown by the target of an invocation.
      Source=mscorlib
      StackTrace:
           at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
           at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
           at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
           at System.Delegate.DynamicInvokeImpl(Object[] args)
           at System.Delegate.DynamicInvoke(Object[] args)
           at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
           at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs)
           at System.Windows.Threading.DispatcherOperation.InvokeImpl()
           at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
           at System.Threading.ExecutionContext.runTryCode(Object userData)
           at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
           at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Windows.Threading.DispatcherOperation.Invoke()
           at System.Windows.Threading.Dispatcher.ProcessQueue()
           at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
           at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
           at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
           at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs)
           at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
           at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
           at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
      InnerException: System.InvalidCastException
           Message=Specified cast is not valid.
           Source=Microsoft.VisualStudio.Platform.WindowManagement
           StackTrace:
                at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.UpdateDocumentIcon()
           InnerException:


    Thursday, January 28, 2010 1:12 PM
  • My apologies, this is a new question, I've posted it here:
    http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/532325db-ccdd-43b6-a1cb-925839eca43c

    Thursday, January 28, 2010 2:41 PM