Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

MEF composition errros when using FileSystemMirroring in a different extension #2517

Closed
Boddlnagg opened this issue Oct 15, 2016 · 3 comments

Comments

@Boddlnagg
Copy link

I'm trying to use Microsoft.VisualStudio.ProjectSystem.FileSystemMirroring in VisualRust. I understand that this is probably not (yet) a supported scenario, but I got it to work quite well. However, I'm still getting MEF composition errors when both RTVS and VisualRust are installed.

----- CompositionError level 1 ------
VisualRust.ProjectSystem.RustProjectSourceItemProviderExtension.ctor(temporaryItems): expected exactly 1 export of Microsoft.VisualStudio.ProjectSystem.FileSystemMirroring.Project.IFileSystemMirroringProjectTemporaryItems but found 2.
    VisualRust.ProjectSystem.LoadHooks.Project
    Microsoft.VisualStudio.R.Package.ProjectSystem.RProjectLoadHooks.Project
   part definition VisualRust.ProjectSystem.RustProjectSourceItemProviderExtension

Microsoft.VisualStudio.R.Package.ProjectSystem.RProjectSourceItemProviderExtension.ctor(temporaryItems): expected exactly 1 export of Microsoft.VisualStudio.ProjectSystem.FileSystemMirroring.Project.IFileSystemMirroringProjectTemporaryItems but found 2.
    VisualRust.ProjectSystem.LoadHooks.Project
    Microsoft.VisualStudio.R.Package.ProjectSystem.RProjectLoadHooks.Project
   part definition Microsoft.VisualStudio.R.Package.ProjectSystem.RProjectSourceItemProviderExtension

Since I think these issues can be fixed quite easily, I'm reporting them here even though VisualRust now loads successfully in spite of those errors. I'm not sure if this is the right way, but I was able to get rid of the errors by using an OrderPrecedenceImportCollection (as described here) for the _temporaryItems in FileSystemMirroringProjectSourceItemProviderExtensionBase, and adding AppliesTo attributes to the FileSystemMirroringProject Project export in RProjectLoadHooks (and my own LoadHooks class).

Furthermore, I think the ProjectItemDependencyProvider also should have an AppliesTo attribute.

By the way, it would be great if Microsoft.VisualStudio.ProjectSystem.FileSystemMirroring could be published on NuGet some day!

@Boddlnagg Boddlnagg changed the title MPF composition errros when using FileSystemMirroring in a different extension MEF composition errros when using FileSystemMirroring in a different extension Oct 15, 2016
@MikhailArkhipov
Copy link
Contributor

How exactly are you reusing the component? VisualRust may be loading OK, but R Tools most probably will stop working due to multiple MEF exports that it is not expecting. Since in VS 15 RTVS come in box and not as extension, this may not be a good idea.

Also, Microsoft.VisualStudio.ProjectSystem.FileSystemMirroring may or may not be present in VS as either of components that implement disk-based file system may not be installed by the user. There are two file mirroring project systems in VS (Cordova and RTVS) - they are forks and are not reusing the same code base.

FMPS is relatively small component you probably want copy the code and change the namespace - check legal copyright of course for applicability.

@Boddlnagg
Copy link
Author

We have already copied the code. If you say that changing the namespace is the best option, we're going to do that. Thanks!

@MikhailArkhipov
Copy link
Contributor

Yes, that will separate interface definition so MEF won't be finding duplicates.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants