locked
VS 2010: Hosting the C# editor in a tool window RRS feed

  • Question

  • Hi,

     

    I'm trying to create a tool window with VS 2010 that contains a C# code editor with intellisense and syntax coloring enabled. I've managed to use the http://code.msdn.microsoft.com/EditorToolwindow sample to get a basic C# editor working (using SetLanguageServiceID and the C# editor GUID), but it doesn't have intellisense.

    Also, once I do get intellisense working, how do I provide a context for it when it's not associated with a project? Mainly, I'd like to add more assemblies that will be recognized by the language service (unrelated to any open project).

     

    Thanks,

    Aelij.

    Sunday, April 25, 2010 7:24 AM

All replies

  • Hi Aelij,

    Thanks for your post.

    How do you use SetLanguageServiceID function? The GUID of the CSharp Language Service is:{694DD9B6-B865-4C5B-AD85-86356E9C88DC}, please refer to following code:

    public static Guid guidVCSLangSvc = new 
    Guid("{694DD9B6-B865-4C5B-AD85-86356E9C88DC}");
    IVsTextLines textLines = Marshal.GetObjectForIUnknown(objPtr) 
    as IVsTextLines;
    textLines.SetLanguageServiceID(ref GuidList.guidVCSLangSvc);

    For more information, please check Dr.eX's blog: Hosting Code Editor in Tool Windows .

    And for your reference, there is a similiar thread with this question in MSDN forums:

    Extending core C# Language Service

    If you have any comments, please feel free to let me know.

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    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.
    Monday, April 26, 2010 9:05 AM
  • Hi Nancy,

     

    In his article Dr.eX's article says "the bigger unknown to me is how to hook up intellisense", which is the same problem I have. I used a similar technique to invoke the SetLanguageServiceID method (I don't need the mashalling since it's VS 2010 so it's all managed). The other article deals with extending the language service, and I don't need to do that either. I want to use it as it is.

    The result I get is a code window with C# keyword colorization, but no context -- it doesn't recognize the structure of the file, there's no brace matching and no intellisense.

    If you open a standalone C# file in VS you get so much more. Can I create that in my tool window?

     

    Thanks,

    Aelij.

    Monday, April 26, 2010 9:23 AM
  • Hi Aelij,

    Sorry for the delay.

    I have download EditorToolWindow sample from the link you provided, and add following sentence in this sample:

     Guid guidLangSvc = new Guid("694DD9B6-B865-4C5B-AD85-86356E9C88DC"); 
    // CSharp Language Service.
     bufferAdapter.SetLanguageServiceID(ref guidLangSvc);
    

    Yes, the result is a code window with C# keyword colorization, but no intellisense. I guess we need to use IVsIntellisenseProject interface to achieve this, but I have not got the result yet, and I will update you as soon as I get anything out.

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    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, May 4, 2010 3:51 AM
  • Hi Nancy,

    I'm facing exactly the same issue, any resolution yet?

    Thanks

    Friday, October 1, 2010 8:54 PM