locked
"Walkthrough: Displaying Statement Completion" does not work RRS feed

  • Question

  • Hello,

    I've been trying to get the code from the walkthrough named "Displaying Statement Completion" to work, but I'm at a loss as to why it doesn't.

    First I'd like to mention that there is an error within the walkthrough, easily overcome but still kind of annoying when it is the first walkthrough that you try to do. The walkthrough mentions that you need to create a file called "TestCompletionCommandHandler", but it then tells you to fill this file with a class named "TestCompletionHandlerProvider". The file that you have to create after it, is again called "TestCompletionCommandHandler", which is then correctly filled with the class by the same name. Obviously the first file that you need to create, should be called "TestCompletionHandlerProvider" and not "TestCompletionCommandHandler".

    Second, when you implement the code as mentioned in the walkthrough, you start it up, type a character, you will immediately get a NullReferenceException after the line "this.TriggerCompletion()" (line 79). If I debug it, I can see that session.Start is called and immediately the OnSessionDismissed method is called, setting the session to null, which in turn will cause the NullReferenceException later on. Also, during debugging, I see that TryCreateCompletionSource (in class TestCompletionSourceProvider) is never called. I assume that has something to do with why the session is dismissed immediately, because there are no completions to do, but why it is not called, I don't know.

    Does anyone have an idea as to why this is not working?

    I'm using Visual Studio 2013 on Windows 8.1 Pro.


    • Edited by Blizzeye Saturday, April 25, 2015 5:15 PM
    Saturday, April 25, 2015 5:11 PM

All replies

  • Hi,

    Welcome to post in MSDN forums.

    I went through this walkthrough:

    Displaying Statement Completion

    And successfully created and debugged the MEF project.  I suspect that the experimental instance of VS2013 on your machine is damaged for some cause, so you'll get some unpredictable exceptions during debugging. Try these steps to reset the experimental instance, then try to debug the project again.

    1. Close any running instance of VS Experimental.
    2. Delete the entire folder %LocalAppData%\Microsoft\VisualStudio\12.0Exp
    Run regedit.exe
    3. Delete the registry key HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0Exp
    4. Delete the registry key HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0Exp_Config
    5. Run the command “Reset the Microsoft Visual Studio 2013 Experimental instance” from your start menu.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    • Edited by Caillen Monday, April 27, 2015 7:22 AM
    Monday, April 27, 2015 7:20 AM
  • I cleaned out my experimental instance with the commands you gave me, and I completely redid the walkthrough. I still have the exact same problem, a null-reference exception in TestCompletionCommandHandler.cs, line 84.

    I tried using .Net 4.5 and .Net 4.5.1, both gave the exact same problem.

    Also, if you strictly follow the walkthrough, it won't even compile because no usings are given for the 2nd and 4th file. With ReSharper, it's not so much a problem, but it still puzzles me that at least 2 people now have said that they have followed the walkthrough and were successfully able to run it, while it shouldn't even compile.

    Monday, April 27, 2015 3:41 PM
  • Does anybody have any idea how to successfully go through the walkthrough?
    Saturday, May 2, 2015 3:07 PM
  • Hi Blizzeye,

    Thefirst time I created the project by following this walkthrough, and then reset the Visual Studio experimental instance, it worked fine, but the second time I debug the code, I encountered the same problem as yours. I cna't figure out what's the root cause of the problem now, so I'll involve some other engineer into this case. If there're any updates, we'll come back.

    Thanks for your understanding.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, May 4, 2015 10:23 AM
  • Hi Blizzeye,

    Since it's the problem with the documentation, and I've reproduced the problem, I send a feedback in Microsoft Connect here:

    https://connect.microsoft.com/VisualStudio/feedback/details/1304669

    You could check the comments by Microsoft. Hope they'll give us a good solution about this problem.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, May 5, 2015 9:58 AM
  • Thanks for your reply Caillen Zhong. I'm very glad to know that it's not just me that is experiencing this problem. I also tried it on another machine (on which I never did any extension programming before) and it gave the exact same problem.

    I'll keep an eye on your post on Microsoft Connect. Hope they will be able to clear it up.

    Tuesday, May 5, 2015 5:34 PM
  • I have the same problem. The reason why it isn't working is that the session doesn't get started in TriggerCompilation. And the reason why the session doesn't start is that the completion source doesn't get created for some reason.

    You can see this by setting a break point to the completion source constructor.

    Also the exception says "An exception of type 'System.InvalidOperationException' occurred in Microsoft.VisualStudio.Platform.VSEditor.dll but was not handled in user code Additional information: Cannot Filter.  The session is not yet started."

    Wednesday, November 4, 2015 11:33 AM
  • Hi all.

    I have (had) the same problem and search several hours to find a solution or workaround.

    (Mostly) VS didn't call "TestCompletionSourceProvider.TryCreateCompletionSource(...)" and without the instanced class "TestCompletionSource" incl. missing call of "AugmentCompletionSession" the "m_provider.CompletionBroker.CreateCompletionSession()" have no chance to create a valid session.

    m_session.Start() raise instant the "SessionDismissed"-Event and "m_session" gets back to NULL before the "TriggerCompletion" leaved

    result: m_session.Filter() - crashed...

    --- workaround found ! ---

    Back to the TestCompletionSourceProvider-Class:

    i don't know why, but if I change the Name-Attribute to "token completion2" or any other name, the extension compiled and started normal and I've never seen the error again...

    rename it to old "token completion" and the problem comes back... :-)

    checked on "Win 8.1 + VS 2013 Update 4" and "Win 7 Pro + VS 2013 Update 5"...

    ps: sorry for my bad english :-)

    • Proposed as answer by Antonio Vale Saturday, December 15, 2018 3:23 AM
    Thursday, November 12, 2015 10:12 PM
  • thank you MaxKlaxxMiner
    something is definitely wrong with that name, but changing it solved for me too.


    • Edited by Antonio Vale Saturday, December 15, 2018 3:24 AM
    Saturday, December 15, 2018 3:23 AM