locked
MEF Composition exception: ..not assignable to type..? RRS feed

  • Question

  • Hi,

    I am making a VS2010 solution template to make editors for domain-specific languages. These editors are MEF extensions to visual studio editor. 

    One of the requirements is, that more than one of these editors has to be installed and working at the same time (each for specific file extension, of course).

    I am able to make editors and install them. When using them, only one of the installed editors works properly (colorizing etc.) and when trying to use another editor, a System.ComponentModel.Composition.CompositionException is thrown as shown below.

    Questions:

    1. How can I review the CompositionException.Errors property (that is mentioned in the exception)?

    2. What might cause this exception? Assemblies or MEF parts overlapping somehow..?

     

    System.ComponentModel.Composition.CompositionException: The composition produced a single composition error, with 2 root causes. The root causes are provided below. Review the CompositionException.Errors property for more detailed information. 1) The export 'Microsoft.VisualStudio.Text.Classification.Implementation.ClassificationTypeRegistryService (ContractName="Microsoft.VisualStudio.Text.Classification.IClassificationTypeRegistryService")' is not assignable to type 'Microsoft.VisualStudio.Text.ITextBuffer'. Resulting in: Cannot set import 'DSL.Editor.TextCompletionSource._buffer (ContractName="Microsoft.VisualStudio.Text.Classification.IClassificationTypeRegistryService")' on part 'DSL.Editor.OutliningTagger'. Element: DSL.Editor.TextCompletionSource._buffer (ContractName="Microsoft.VisualStudio.Text.Classification.IClassificationTypeRegistryService") --> DSL.Editor.OutliningTagger Resulting in: Cannot get export 'DSL.Editor.OutliningTagger (ContractName="Microsoft.VisualStudio.Text.Tagging.ITaggerProvider")' from part 'DSL.Editor.OutliningTagger'. Element: DSL.Editor.OutliningTagger (ContractName="Microsoft.VisualStudio.Text.Tagging.ITaggerProvider") --> DSL.Editor.OutliningTagger 2) The export 'Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregatorFactoryService (ContractName="Microsoft.VisualStudio.Text.Tagging.IBufferTagAggregatorFactoryService")' is not assignable to type 'System.Boolean'. Resulting in: Cannot set import 'DSL.Editor.TextCompletionSource._disposed (ContractName="Microsoft.VisualStudio.Text.Tagging.IBufferTagAggregatorFactoryService")' on part 'DSL.Editor.OutliningTagger'. Element: DSL.Editor.TextCompletionSource._disposed (ContractName="Microsoft.VisualStudio.Text.Tagging.IBufferTagAggregatorFactoryService") --> DSL.Editor.OutliningTagger Resulting in: Cannot get export 'DSL.Editor.OutliningTagger (ContractName="Microsoft.VisualStudio.Text.Tagging.ITaggerProvider")' from part 'DSL.Editor.OutliningTagger'. Element: DSL.Editor.OutliningTagger (ContractName="Microsoft.VisualStudio.Text.Tagging.ITaggerProvider") --> DSL.Editor.OutliningTagger at System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine engine, ComposablePart part, ExportDefinition definition) at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(ComposablePart part, ExportDefinition export, Boolean isSharedPart) at System.ComponentModel.Composition.Hosting.CatalogExportProvider.CatalogExport.GetExportedValueCore() at System.ComponentModel.Composition.Primitives.Export.get_Value() at System.ComponentModel.Composition.ExportServices.GetExportedValueFromLazy[T](Export export) at System.ComponentModel.Composition.ExportServices.<>c__DisplayClass4`2.<CreateStronglyTypedExportOfTM>b__1() at System.Lazy`1.CreateValue() at System.Lazy`1.LazyInitValue() at System.Lazy`1.get_Value() at Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator`1.GatherTaggers(ITextBuffer textBuffer)

     

    Thanks for your help in advance.


    • Edited by mmatinla Thursday, December 29, 2011 10:33 AM
    Thursday, December 29, 2011 10:32 AM

Answers

  • Got it.

    Assembly names have to be unique in each instance of editor.

    • Marked as answer by mmatinla Thursday, December 29, 2011 4:20 PM
    Thursday, December 29, 2011 4:20 PM

All replies

  • Got it.

    Assembly names have to be unique in each instance of editor.

    • Marked as answer by mmatinla Thursday, December 29, 2011 4:20 PM
    Thursday, December 29, 2011 4:20 PM
  • Hi mmatinla,

    I’m glad to hear that you got it working.

    Thank you for sharing your solutions & experience here. It will be very beneficial for other community members who have similar questions.

     

    Best regards,

    Lucy


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us
    Friday, December 30, 2011 5:00 AM