locked
OpenDocumentViaProjectWithSpecific for html files doesn't work? RRS feed

  • Question

  • Hi,

    I want to open an html file using xml editor. The code mentioned below works, but the file opens in the html editor .

     IVsUIShellOpenDocument shellOpenDoc = GetService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
        IVsUIHierarchy pUIHier;
        uint itemID;
        Guid logicalView = VSConstants.LOGVIEWID_Code;
        Microsoft.VisualStudio.OLE.Interop.IServiceProvider ppSP;
        Guid editorType = new Guid("{FA3CD31E-987B-443A-9B81-186104E8DAC1}"); // Xml editor factory
        IVsWindowFrame docFrame;
        ErrorHandler.ThrowOnFailure(shellOpenDoc.OpenDocumentViaProjectWithSpecific(@"D:\22.html", (uint)(__VSSPECIFICEDITORFLAGS.VSSPECIFICEDITOR_UseEditor | __VSSPECIFICEDITORFLAGS.VSSPECIFICEDITOR_DoOpen), ref editorType, null, ref logicalView, out ppSP, out pUIHier, out itemID, out docFrame));
        docFrame.Show();

    If you replace editorType with the text editor, the latter will open. I suppose that this does not work only for xml editors, but I can open the html file in the xml editor by selecting "Open With" command in the context menu of the solution explorer. Where am I wrong?

    Thanks,
    Ivan

    Wednesday, February 24, 2010 1:36 PM

Answers

  • Hi Ivan,

    The problem was that when something was already opened in the VS editor, subsequent attempts to open it with a different editor would fail (it would, instead, just bring focus to the pre-existing editor). It have been fixed in Visual Studio 2010 Version 10.0.21006 or above. So I highly suggest you using high version of Visual Studio.

    Please let me know if you have any comments.

    Best Regards,
    Nancy
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Nancy Shao Thursday, March 4, 2010 2:36 AM
    Thursday, March 4, 2010 2:35 AM

All replies

  • Hi Ivan,

    Which version of Visual Studio do you use? I can reproduce this issue in Visual Studio 2008, but it works fine in Visual Studio 2010: html file will be opened with XML editor. I am sure the cause, and I'm consulting with our Product Group, and will let you know the result soon.

    If you really want to do this function, I would suggest you using Visual Studio 2010 instead.

    Best Regards,
    Nancy
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, March 2, 2010 5:39 AM
  • Hi Ivan,

    The problem was that when something was already opened in the VS editor, subsequent attempts to open it with a different editor would fail (it would, instead, just bring focus to the pre-existing editor). It have been fixed in Visual Studio 2010 Version 10.0.21006 or above. So I highly suggest you using high version of Visual Studio.

    Please let me know if you have any comments.

    Best Regards,
    Nancy
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Nancy Shao Thursday, March 4, 2010 2:36 AM
    Thursday, March 4, 2010 2:35 AM
  • Hi Nancy,

    Everything does work ok in Vs2010, but I need Vs2008. You wrote that the problem was caused by some opened editor, but my xml editor never opens, even if there is no opened editor, all the more any html editor for an opened document . However, the "Open with" command works correctly. Can you write the code of  the command handler, as it does the right way I need?

    Thanks,
    Ivan

    Thursday, March 4, 2010 11:11 AM
  • Hi IvanOs,

    Based on my research, I have not found the cause. If you really care this cause, I highly suggest you submit this issue on our Connect portal site:

        https://connect.microsoft.com/VisualStudio/

    In your feedback, you can quote the URL to this thread, so that the whole conversation can be available. Every feedback submitted will be evaluated carefully by our engineers. They will let you know their comments further through that portal. It would be great if you can also paste the link to the submitted feedback here, so that other community members can see it as well.

    Best Regards,
    Nancy


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, March 5, 2010 3:16 AM
  • Unfortunately it is unlikely that a patch will be released for this for VS2008.  But, I'm curious - does this only happen when you have a .html extension?  What if the file has a .txt extension?  I'm curious if the issue is that the XML editor isn't open an HTML file or the XML editor isn't correctly opening any file.
    http://blogs.msdn.com/amyd/
    Tuesday, March 9, 2010 9:03 PM
  • Yes,  this happen when I have a .html extension, for ohter extensions all work fine. I think that it's an XML editor problem.
    Tuesday, March 23, 2010 10:37 AM