DynamicEnumProperty provider class that implements IDynamicEnumValuesProvider not being loaded by Visual Studio 2013 RRS feed

  • Question

  • Hello I have a managed package that provides the code for a custom C++ build toolchain. I have a custom platform Toolset.targets that loads some custom properties:

        <PropertyPageSchema Include="$(MSBuildThisFileDirectory)projprops.xml" />

    projprops.xml looks like the following:

    <?xml version="1.0" encoding="utf-8"?>
    <Rule Name="MyGeneralProperties"
            <Category Name="General" DisplayName="General" Description="General" />
            <DataSource Persistence="UserFile"/>
        <DynamicEnumProperty Name="BuildMachine" DisplayName="Build Machine" Category="General" EnumProvider="BuildMachines" Visible="True" Description="The machine that building and debugging will take place on."/>
    I have my enum provider in the same DLL as the package and it looks like this:

    [Export(typeof(IDynamicEnumValuesProvider))] [DynamicEnumCategory("BuildMachines")] public class BuildMachineEnumProvider : IDynamicEnumValuesProvider { // the implementation }
    An instance of BuildMachineEnumProvider is never created by the runtime however the property shows up in the VC project properties right where it's supposed to. The package loads as it should when a solution is loaded via [ProvideAutoLoad(UIContextGuids80.SolutionExists)]. According to everything I've read MEF should recognize my enum provider class when the package is loaded and everything else should just work - except it doesn't.

    me vs Visual Studio .NET 2005 SDK - round 249873 - FIGHT!

    Wednesday, December 3, 2014 8:58 PM

All replies

  • In your VSPackage (or any MEF-exposed DLL referenced by it) create a class implementing IDynamicEnumValuesProvider and add [Export(typeof(IDynamicEnumValuesProvider)), DynamicEnumCategory("MyCategory")] to that class's attributes. Then add EnumProvider="MyCategory" to the DynamicEnumProperty definition and your class will be used as the values provider.
    Make sure your package references Microsoft.VisualStudio.ProjectSystem.Utilities.v12.0.dll and Microsoft.VisualStudio.ProjectSystem.V12Only.dll (for VS2013) or similar assemblies for earlier versions.
    Monday, December 8, 2014 10:37 AM
  • This is exactly what I am doing and it isn't working.

    me vs Visual Studio .NET 2005 SDK - round 249873 - FIGHT!

    Monday, December 8, 2014 3:07 PM
  • You need to mark your VSPackage as MEF-enabled, so it scans through your assemblies. This requires some magic entry in source.extension.vsixmanifest.

    Check this post for details: http://stackoverflow.com/questions/18090422/does-anyone-know-how-to-implement-the-dynamicenumproperty-type-for-c-project-p/29291231#29291231


    Pawel Hofman

    Friday, March 27, 2015 12:26 AM