Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
OpenDocumentViaProject Method

IVsUIShellOpenDocument.OpenDocumentViaProject Method

Finds an appropriate project to open the document.

Namespace: Microsoft.VisualStudio.Shell.Interop
Assembly: Microsoft.VisualStudio.Shell.Interop (in microsoft.visualstudio.shell.interop.dll)

int OpenDocumentViaProject (
	[InAttribute] string pszMkDocument,
	[InAttribute] ref Guid rguidLogicalView,
	out IServiceProvider ppSP,
	out IVsUIHierarchy ppHier,
	out uint pitemid,
	out IVsWindowFrame ppWindowFrame
int OpenDocumentViaProject (
	/** @attribute InAttribute() */ String pszMkDocument, 
	/** @attribute InAttribute() */ /** @ref */ Guid rguidLogicalView, 
	/** @attribute OutAttribute() */ /** @ref */ IServiceProvider ppSP, 
	/** @attribute OutAttribute() */ /** @ref */ IVsUIHierarchy ppHier, 
	/** @attribute OutAttribute() */ /** @ref */ UInt32 pitemid, 
	/** @attribute OutAttribute() */ /** @ref */ IVsWindowFrame ppWindowFrame
JScript does not support passing value-type arguments by reference.



[in] String form of the unique moniker identifier of the document in the project system. If the document is a file, you can simply specify the file extension for this parameter rather than the full path to the file (for example, .bmp or txt). In non-file cases, this identifier is often in the form of a URL.


[in] Unique identifier of the logical view. If the editor implements IVsMultiViewDocumentView on the document view object, then the value passed into the rguidLogicalView parameter determines which view is activated when the editor window is shown, when the editor is instantiated. By specifying the logical view GUID, you can request the specific view that matches the reason you are requesting the view. For example, specify LOGVIEWID_Debugging to get the view appropriate for debugging, or LOGVIEWID_TextView to get the view appropriate for the text editor (that is, a view that implements IVsCodeWindow).


[out] Pointer to the IServiceProvideroledbinterfaces_implemented_by_the_provider interface.


[out] Pointer to the IVsUIHierarchy interface of the project that can open the document.


[out] Pointer to the hierarchy item identifier of the document in the project. For more information see VSITEMID.


[out, retval] Pointer to the window frame that contains the editor. For more information, see IVsWindowFrame.

Return Value

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

COM Signature

From vsshell.idl:

HRESULT IVsUIShellOpenDocument::OpenDocumentViaProject(
   [in] LPCOLESTR pszMkDocument,
   [in] REFGUID rguidLogicalView,
   [out] IServiceProvider **ppSP,
   [out] IVsUIHierarchy **ppHier,
   [out] VSITEMID *pitemid,
   [out, retval] IVsWindowFrame **ppWindowFrame

IVsUIShellOpenDocument.OpenDocumentViaProject can be called to open any project that is opened through the New Project or Open Project dialog box. In addition, this method is also called to open a document in any project that is added to the solution through AddVirtualProject or AddVirtualProjectEx. One example use of this is the DataView hierarchy, which is currently in Server Explorer. If a DataView hierarchy is added to the solution as a virtual project using AddVirtualProject, then the OpenDocumentViaProject method can open items from DataView hierarchies. This functionality is important as it makes debugging of stored procedures possible.

Community Additions

© 2015 Microsoft