locked
IHtmlCompletionListProvider for VS2015 and VS2017 RRS feed

  • Question

  • Hi,

    I have created extension that use IHtmlCompletionListProvider. I would like to support Visual Studio 2015 and Visual Studio 2017 but when I run my completion on Visual Studio 2017 I receive the following exception:

    System.ComponentModel.Composition.CompositionContractMismatchException:
    	Cannot cast the underlying exported value of type 'Microsoft.Html.Editor.Completion.Def.IHtmlCompletionListProvider' to type 'Microsoft.Html.Editor.Completion.Def.IHtmlCompletionListProvider'.
    		at System.ComponentModel.Composition.ExportServices.CastExportedValue[T](ICompositionElement element, Object exportedValue)
    		at System.ComponentModel.Composition.ExportServices.GetCastedExportedValue[T](Export export)
    		at System.ComponentModel.Composition.ExportServices.<>c__DisplayClass11_0`2.<CreateStronglyTypedLazyOfTM>b__1()
    		at System.Lazy`1.CreateValue() at System.Lazy`1.LazyInitValue() at System.Lazy`1.get_Value()
    		at Microsoft.Html.Editor.Completion.Engine.HtmlCompletionEngine.GetElementCompletionProviders(String completionType, String elementPrefix, String elementName)
    		at Microsoft.Html.Editor.Completion.Engine.HtmlCompletionEngine.GetCompletionForAttributes(ElementNode element, String& completionType)
    		at Microsoft.Html.Editor.Completion.Engine.HtmlCompletionEngine.GetAttributeNameCompletions(RootNode rootNode, Int32 position, ElementNode element, AttributeNode attribute, ITextRange& range, String& completionType)
    		at Microsoft.Html.Editor.Completion.Engine.HtmlCompletionEngine.GetCompletionForLocation(RootNode rootNode, IContentType contentType, Int32 position, ElementNode& element, AttributeNode& attribute, ITextRange& range, String& completionType, Boolean autoShownCompletion)
    		at Microsoft.Html.Editor.Completion.HtmlCompletionSource.PopulateCompletionList(Int32 position, ICompletionSession session, IList`1 completionSets) at Microsoft.Html.Editor.Completion.HtmlCompletionSource.AugmentCompletionSession(ICompletionSession session, IList`1 completionSets)
    		at Microsoft.VisualStudio.Language.Intellisense.Implementation.CompletionSession.Start()
    		at Microsoft.VisualStudio.Language.Intellisense.Implementation.CompletionBroker.TriggerCompletion(ITextView textView)
    		at Microsoft.Web.Editor.Completion.CompletionController.TriggerCompletion()
    		at Microsoft.Web.Editor.Completion.CompletionController.ShowCompletion(Boolean autoShownCompletion)
    		at Microsoft.Web.Editor.Completion.CompletionController.OnPostTypeChar(Char typedCharacter)
    		at Microsoft.Html.Editor.Completion.HtmlCompletionController.OnPostTypeChar(Char typedCharacter)
    		at Microsoft.Web.Editor.Completion.TypingCommandHandler.OnPostTypeChar(Char typedChar)
    		at Microsoft.Web.Editor.Completion.TypingCommandHandler.PostProcessInvoke(CommandResult result, Guid group, Int32 id, Object inputArg, Object& outputArg)
    		at Microsoft.Html.Editor.Commands.HtmlTypingCommandHandler.PostProcessInvoke(CommandResult result, Guid group, Int32 id, Object inputArg, Object& outputArg)
    		at Microsoft.Web.Editor.Controller.Controller.Invoke(Guid group, Int32 id, Object inputArg, Object& outputArg)
    		at Microsoft.Web.Editor.Controller.ViewController.Invoke(Guid group, Int32 id, Object inputArg, Object& outputArg)
    		at Microsoft.Html.Editor.Commands.HtmlMainController.Invoke(Guid group, Int32 id, Object inputArg, Object& outputArg)
    		at Microsoft.VisualStudio.Html.Interop.CommandTargetToOleShim.Exec(Guid& guidCommandGroup, UInt32 commandID, UInt32 commandExecOpt, IntPtr variantIn, IntPtr variantOut)
    		at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.InnerExec(Guid& pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
    		at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.Exec(Guid& pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
    		at Rosieks.VisualStudio.Angular.Commands.CommandTargetBase`1.Exec(Guid& pguidCmdGroup, UInt32 nCmdID, UInt32 nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
    		

    I suppose the reason of that is that I have referenced Microsoft.Html.Editor from Visual Studio 2015 and it cannot cast it to version 2017. Can I solve it without creating to separate extensions?

    Friday, April 14, 2017 6:00 AM

All replies

  • Hi Sławomir Rosiek,

    According to your description, I try to search related content about IHtmlCompletionListProvider, but I could not find related Microsoft document of the API, Could you please provide a bit more information about IHtmlCompletionListProvider.

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 17, 2017 9:27 AM
  • So it was your plugin :|
    I spend days, disabled almost every plugin and every snippet pack but angular productivity and couldn't find out about why am I getting such problem :| Thank you for submitting this and I could find out with a search!

    Please remove 2017 version from your plugin, Thanks.

    Tuesday, April 18, 2017 4:50 AM
  • Hi Sijav,

    Do you open the extension by using visual studio 2017 and debug the project. and check what line of code cause the issue.

    Best regards,

    Cole Wu


    MSDN Community Support<br/> Please remember to click &quot;Mark as Answer&quot; the responses that resolved your issue, and to click &quot;Unmark as Answer&quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact <a href="mailto:MSDNFSF@microsoft.com">MSDNFSF@microsoft.com</a>.

    Friday, April 21, 2017 7:51 AM
  • Hi,

    IHtmlCompletionListProvider is interface that let you extend HTML editor by providing additional autocomplete. Unfortunately Visual Studio extensibility is not so well documented so you will probably don't find any information in MSDN, but you can find it a lot when you look at Mads Kristensen Web Essentials extension.

    I think that the problem is not caused exactly by my code but rather MEF that tries to load my plugin but it use type from Visual Studio 2015 instead of 2017.

     

    Tuesday, April 25, 2017 6:52 PM
  • Hi Sławomir Rosiek,

    Please download Web Essentials 2017 and install it. Then use IHtmlCompletionListProvider of Web Essentials and check if it works for you.

    Best regards,

    Cole Wu


    MSDN Community Support&lt;br/&gt; Please remember to click &amp;quot;Mark as Answer&amp;quot; the responses that resolved your issue, and to click &amp;quot;Unmark as Answer&amp;quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact &lt;a href=&quot;mailto:MSDNFSF@microsoft.com&quot;&gt;MSDNFSF@microsoft.com&lt;/a&gt;.

    Thursday, May 4, 2017 8:44 AM