gpt4 book ai didi

visual-studio-2010 - IClassifierProvider 未启动

转载 作者:行者123 更新时间:2023-12-04 02:55:04 24 4
gpt4 key购买 nike

我正在尝试为 visual studio 构建输出添加颜色。所以我试图获得 IClassifierProvider 的分类器。但是 GetClassifier() 没有被调用。可能是什么问题呢?源代码示例如下。当我尝试使用 VSColorOutput 扩展时,它会启动。请告诉我我缺少什么?

 [ContentType("output")]
[Export(typeof(IClassifierProvider))]
public class OutputClassifierProvider : IClassifierProvider
{
[Import]
internal IClassificationTypeRegistryService ClassificationRegistry;

[Import]
internal SVsServiceProvider ServiceProvider;

public static OutputClassifier OutputClassifier { get; private set; }

public IClassifier GetClassifier(ITextBuffer buffer)
{
MessageBox.Show("asd");
try
{
if (OutputClassifier == null)
{
OutputClassifier = new OutputClassifier();

}
}
catch (Exception ex)
{
throw;
}
return OutputClassifier;
}
}
public class OutputClassifier: IClassifier
{
public event EventHandler<ClassificationChangedEventArgs> ClassificationChanged;

public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
{
return new List<ClassificationSpan>();
}
}

Vsix list

<?xml version="1.0" encoding="utf-8"?>
<Vsix xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2010">
<Identifier Id="3ac9d6e9-a3dc-4a27-a048-f4bb7fe5889b">
<Name>Sample</Name>
<Author>Company</Author>
<Version>1.0</Version>
<Description xml:space="preserve">It conatains set of features which will ease the life of Atmel Studio user.</Description>
<Locale>1033</Locale>
<InstalledByMsi>false</InstalledByMsi>
<SupportedProducts>
<VisualStudio Version="10.0">
<Edition>Pro</Edition>
</VisualStudio>
</SupportedProducts>
<SupportedFrameworkRuntimeEdition MinVersion="4.0" MaxVersion="4.0" />
</Identifier>
<References>
<Reference Id="Microsoft.VisualStudio.MPF" MinVersion="10.0">
<Name>Visual Studio MPF</Name>
</Reference>
</References>

<Content>
<VsPackage>XFeatures.pkgdef</VsPackage>
</Content>
</Vsix>

最佳答案

感谢 Jason Malinowski 我分析了 list 代码,发现那里缺少 MEF 内容。将 MEF 添加到内容标签后,它现在可以工作了。

 <Content>
<VsPackage>|%CurrentProject%;PkgdefProjectOutputGroup|</VsPackage>
<MefComponent>|%CurrentProject%|</MefComponent>
</Content>

关于visual-studio-2010 - IClassifierProvider 未启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16816477/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com