导入SVsServiceProvider无法在自定义编辑器中工作

Mat*_*her 8 c# visual-studio winforms

我为WinForms组件创建了一个自定义编辑器,它实现了UITypeEditor并且工作正常.编辑器应该从当前打开的解决方案中加载信息,我认为这应该通过VisualStudio SDK中的DTE完成.

根据MSDN文章(http://msdn.microsoft.com/en-us/library/ee834473(v=vs.110).aspx),我实现了这个:

internal class TreeViewTypeEditor : UITypeEditor
{
     [Import]
     internal SVsServiceProvider ServiceProvider = null;

     protected override Control GetEditControl(ITypeDescriptorContext context, object value)
     {
         // ServiceProvider is NULL here!
         DTE dte = (DTE)ServiceProvider.GetService(typeof(DTE));
     }
}
Run Code Online (Sandbox Code Playgroud)

ServiceProvider永远是空的,但为什么呢?我究竟做错了什么?