Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does visual studio find MEF components in VSIX project?

Tags:

mef

vsix

When a VSIX project that contains MEF components is installed, how does visual studio find the MEF components? I know the regular way could be adding catalogs of dll directories that contains the MEF parts. How does Visual Studio know where to look to find the MEF in VSIX project?

like image 272
Yituo Avatar asked Dec 03 '25 17:12

Yituo


1 Answers

Visual Studio Extensions (VSIX) usually contain a VS Package class, an extension.vsixmanifest file, and zero or more PKGDEF files that provided metadata and extension initialization information to the IDE.

VS is made aware of MEF components via a MefComponent registration in the extension.vsixmanifest file that indicates that a specific assembly should be scanned at MEF cache generation.

The simplest way to declare a MEF component in your extension is to right click on the project, select 'New Item', and add a Package to your project. This will provide the source.extension.vsixmanifest file to which you can add the MEF component registration. Double click this file, and add your registration in the 'Assets' tab of the VSIX manifest designer.

like image 53
Christian Gunderman Avatar answered Dec 07 '25 14:12

Christian Gunderman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!