microsoft / VSExtensibility

A repo for upcoming changes to extensibility in Visual Studio, the new extensibility model, and language server protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Visual Studio MEF components seemingly not available

LaserHydra opened this issue · comments

Hi there,

I followed the walkthrough at https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2015/extensibility/walkthrough-highlighting-text?view=vs-2015&tabs=csharp to add text highlighting into my extension.

Unfortunately, the component fails to load, apparently because the referenced Visual Studio MEF components aren't exported/available:

System.ComponentModel.Composition Warning: 1 : The ComposablePartDefinition 'HighlightWordTaggerProvider' has been rejected. The composition remains unchanged. The changes were rejected because of the following error(s): The composition produced multiple composition errors, with 2 root causes. The root causes are provided below. Review the CompositionException.Errors property for more detailed information.

1) No exports were found that match the constraint: 
	ContractName	Microsoft.VisualStudio.Text.Operations.ITextSearchService
	RequiredTypeIdentity	Microsoft.VisualStudio.Text.Operations.ITextSearchService

Resulting in: Cannot set import 'HighlightWordTaggerProvider.TextSearchService (ContractName="Microsoft.VisualStudio.Text.Operations.ITextSearchService")' on part 'HighlightWordTaggerProvider'.
Element: HighlightWordTaggerProvider.TextSearchService (ContractName="Microsoft.VisualStudio.Text.Operations.ITextSearchService") -->  HighlightWordTaggerProvider -->  AssemblyCatalog (...)

2) No exports were found that match the constraint: 
	ContractName	Microsoft.VisualStudio.Text.Operations.ITextStructureNavigatorSelectorService
	RequiredTypeIdentity	Microsoft.VisualStudio.Text.Operations.ITextStructureNavigatorSelectorService

Resulting in: Cannot set import 'HighlightWordTaggerProvider.TextStructureNavigatorSelector (ContractName="Microsoft.VisualStudio.Text.Operations.ITextStructureNavigatorSelectorService")' on part 'HighlightWordTaggerProvider'.
Element: HighlightWordTaggerProvider.TextStructureNavigatorSelector (ContractName="Microsoft.VisualStudio.Text.Operations.ITextStructureNavigatorSelectorService") -->  HighlightWordTaggerProvider -->  AssemblyCatalog (...)

Importantly, this is an extension for a Visual Studio Isolated Shell application. So far I have been installing it manually, by creating a new sub-directory under the /Extensions directory in the install directory.

I suspect that the MEF component registration via VSIX installer is necessary for this to work properly?
Unfortunately I couldn't seem to create a VSIX targeting the VS Isolated Shell application.

Is this indeed the issue? If so, is there another way for me to properly register my extension to use MEF or generate a VSIX?

Thanks & best regards

Which version of Visual Studio are you building this for? You mentioned building for Isolated Shell, but the last supported version of Isolated Shell is actually VS2015.

If you build the extension specifically for VS, and not Isolated Shell, do you see the same behavior?

@tinaschrepfer Thank you for your quick reply and sorry for my late response.

Yes, I am building for VS15 since the application is based on Isolated Shell 15.

<TargetVSVersion>14.0</TargetVSVersion>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>

I don't think I am specifically building for Isolated Shell actually. How would I do that?

Also in the meantime at some point my MEF components suddenly seemed to be loaded properly and I have been able to use it since. I am not entirely sure what caused this change. I did delete the ComponentModelCache directory, however I believe I tried that before without success.
I also added a reference to Microsoft.Build for an unrelated reason; could that have affected this at all?

Furthermore, is there a way for me to provide a VSIX which can be installed in the Isolated Shell application?

Thank you

@LaserHydra - unfortunately we can't provide in depth support for this as this is specific to your extension and against an application that's based on IsoShell. We do not have the capacity to provide engineering assistance and can only offer assistance to more broad questions. In this case, I recommend building this extension against VS2015 to see if it works. You can check to make sure you've added the appropriate MEF asset in your extension vsixmanifest. That seems to be a common mistake for folks.

I understand many users run into problems diagnosing their VSSDK extensions. Our goal is to improve this experience with VisualStudio.Extensibility. We encourage you to try out the new extensibility model when you get a chance. Thanks!