Visual Studio 扩展中的引用问题
Reference problems in Visual Studio extension
我是 Visual Studio 扩展的新手,尝试了 GitHub 中的一些示例以及此处的一些有用建议,并取得了一些成功。我正在尝试创建一个 ToolWindow 来处理当前打开的解决方案的结构,这在技术上对 Microsoft.VisualStudio.LanguageServices
命名空间没有问题。 ToolWindow 本身就可以工作,只要我不使用该命名空间中的任何东西——特别是下面调用的函数在我的 window:
的构造函数中初始化解决方案信息
private void ReloadSolutionInformation()
{
var componentModel = (IComponentModel)SmartOptionsEditorPackage.GetGlobalService(typeof(SComponentModel));
VisualStudioWorkspace workspace = componentModel.GetService<VisualStudioWorkspace>();
Solution solution = workspace.CurrentSolution;
this.Solutions.Clear(); // some collection of SolutionNode instances
// create and add custom tree node with solution information
var solutionNode = new SolutionNode(solution.FilePath);
this.Solutions.Add(solutionNode);
// recurse through projects etc.
PopulateSolutionWithProjects(solutionNode, solution);
}
当我 运行 在 Visual Studio 2017 的实验实例中调试它时,我在构造函数,调用上述方法的地方:
The File or Assembly "Microsoft.VisualStudio.LanguageServices, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" or one of its dependencies could not be found. The system cannot find the file.
StackTrace: at MyAssembly.MyToolWindow.ReloadSolutionInformation()
at MyAssembly.MyToolWindow..ctor()
at MyAssembly.MyToolWindowPane..ctor()
FileName: Microsoft.VisualStudio.LanguageServices, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
此外,我在构建后注意到以下警告:
CS1762: A reference was created to embedded interop assembly 'Microsoft.VisualStudio.Shell.Interop.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' because of an indirect reference to that assembly created by assembly 'Microsoft.VisualStudio.LanguageServices, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Consider changing the 'Embed Interop Types' property on either assembly.
将构建输出详细程度设置为诊断时,我只发现了上述警告而没有进一步的信息。检查构建输出目录,我看到包含所有引用的 DLL,但 VSIX 中缺少所有 Microsoft.VisualStudio.*
DLL,Microsoft.VisualStudio.Shell.Interop.15.3.DesignTime.dll
除外。据我了解互操作程序集,我认为它们是由 VisualStudio 提供的,所以我不必嵌入它们,对吗?
每个引用的引用 属性 Embed Interop Types
都设置为 false。我试图根据我发现的一些建议对其进行更改,但这没有用。我的目标是 .Net 4.6.2。
经过太多个晚上的失败尝试,尤其是错误,我仍然不知道如何解决这个问题。这包括重新安装 NuGet 包、重新启动所有内容、重置实验实例以及逐步删除和重新添加本地 DLL 和 NuGetPackage 的引用。在以前的编辑中,我发布了一个缩短的项目文件内容,但由于输入字符限制,我现在不得不将其删除。相反,这里是 fusionlog 的输出:
=== Zustandsinformationen vor Bindung ===
LOG: DisplayName = Microsoft.VisualStudio.LanguageServices, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/
LOG: Ursprünglicher PrivatePath = NULL
Aufruf von Assembly : MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: Diese Bindung startet im LoadFrom-Load-Kontext.
WRN: Das systemeigene Image wird nicht im LoadFrom-Kontext durchsucht. Das systemeigene Image wird nur im Standard-Load-Kontext durchsucht, z. B. Assembly.Load().
LOG: Die Anwendungskonfigurationsdatei wird verwendet: C:\Users\me\AppData\Local\Microsoft\VisualStudio.0_15d7a44dExp\devenv.exe.config
LOG: Die Hostkonfigurationsdatei wird verwendet:
LOG: Die Computerkonfigurationsdatei von C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config wird verwendet.
LOG: Verweis nach der Richtlinie: Microsoft.VisualStudio.LanguageServices, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PublicAssemblies/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PublicAssemblies/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/Debugger/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/Debugger/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/x86/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/x86/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PublicAssemblies/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PublicAssemblies/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/Debugger/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/Debugger/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/x86/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/x86/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/USERS/ME/APPDATA/LOCAL/MICROSOFT/VISUALSTUDIO/15.0_15D7A44DEXP/EXTENSIONS/AUTHOR/MY ASSEMBLY/1.0/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/USERS/ME/APPDATA/LOCAL/MICROSOFT/VISUALSTUDIO/15.0_15D7A44DEXP/EXTENSIONS/AUTHOR/MY ASSEMBLY/1.0/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/USERS/ME/APPDATA/LOCAL/MICROSOFT/VISUALSTUDIO/15.0_15D7A44DEXP/EXTENSIONS/AUTHOR/MY ASSEMBLY/1.0/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/USERS/ME/APPDATA/LOCAL/MICROSOFT/VISUALSTUDIO/15.0_15D7A44DEXP/EXTENSIONS/AUTHOR/MY ASSEMBLY/1.0/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.EXE.
您在 this ZIP file 中找到了一个最小的解决方案示例。在这里,我使用新的 VSIX 项目创建了一个新的解决方案,通过向导添加了一个 ToolWindow,添加了我的重要代码,解决了丢失的引用,开始调试并收到了相同的旧 FileNotFoundException
.
有人看到这里的问题吗?提前致谢。
您必须使用 Visual Studio 使用的库版本或更低版本。
对于 Community 2017,可以在
中找到它们
C:\Program Files (x86)\Microsoft Visual
Studio17\Community\Common7\IDE\CommonExtensions\Microsoft\ManagedLanguages\VBCSharp\LanguageServices
现在 Visual Studio 2017 版本 15.2
Microsoft.CodeAnalysis.Workspaces.dll、Microsoft.VisualStudio.LanguageServices.dll、Microsoft.CodeAnalysis.EditorFeatures.Text 有版本 2.2.0。
因此在 NuGet 中将它们安装或更新到版本 2.2.0 而无需将它们包含到 vsix
您可以通过将 <ForceIncludeInVSIX>true</ForceIncludeInVSIX>
添加到 .csproj 文件来将 Microsoft.VisualStudio.LanguageServices 的较新版本包含在 VSIX 中:
<Reference Include="Microsoft.VisualStudio.LanguageServices, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.LanguageServices.2.3.1\lib\net46\Microsoft.VisualStudio.LanguageServices.dll</HintPath>
<ForceIncludeInVSIX>true</ForceIncludeInVSIX>
</Reference>
但随后我们会得到其他错误。
System.InvalidCastException: 'Unable to cast object of type 'Microsoft.VisualStudio.LanguageServices.RoslynVisualStudioWorkspace' to type 'Microsoft.VisualStudio.LanguageServices.VisualStudioWorkspace
Visual Studio2017版本15.3使用2.3.2版本。您的扩展程序使用较低版本 2.2.0 并将在那里工作。如果您将 NuGet 中的组件更新到 2.3.2,扩展将在 15.3 中工作,而在 15.2 中不工作
所以现在使用2.2.0版本
好的,我知道了。
什么都不做,只清理 vsix 项目的 bin
文件夹。其余的都可以正常工作
我是 Visual Studio 扩展的新手,尝试了 GitHub 中的一些示例以及此处的一些有用建议,并取得了一些成功。我正在尝试创建一个 ToolWindow 来处理当前打开的解决方案的结构,这在技术上对 Microsoft.VisualStudio.LanguageServices
命名空间没有问题。 ToolWindow 本身就可以工作,只要我不使用该命名空间中的任何东西——特别是下面调用的函数在我的 window:
private void ReloadSolutionInformation()
{
var componentModel = (IComponentModel)SmartOptionsEditorPackage.GetGlobalService(typeof(SComponentModel));
VisualStudioWorkspace workspace = componentModel.GetService<VisualStudioWorkspace>();
Solution solution = workspace.CurrentSolution;
this.Solutions.Clear(); // some collection of SolutionNode instances
// create and add custom tree node with solution information
var solutionNode = new SolutionNode(solution.FilePath);
this.Solutions.Add(solutionNode);
// recurse through projects etc.
PopulateSolutionWithProjects(solutionNode, solution);
}
当我 运行 在 Visual Studio 2017 的实验实例中调试它时,我在构造函数,调用上述方法的地方:
The File or Assembly "Microsoft.VisualStudio.LanguageServices, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" or one of its dependencies could not be found. The system cannot find the file.
StackTrace: at MyAssembly.MyToolWindow.ReloadSolutionInformation() at MyAssembly.MyToolWindow..ctor() at MyAssembly.MyToolWindowPane..ctor()
FileName: Microsoft.VisualStudio.LanguageServices, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
此外,我在构建后注意到以下警告:
CS1762: A reference was created to embedded interop assembly 'Microsoft.VisualStudio.Shell.Interop.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' because of an indirect reference to that assembly created by assembly 'Microsoft.VisualStudio.LanguageServices, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Consider changing the 'Embed Interop Types' property on either assembly.
将构建输出详细程度设置为诊断时,我只发现了上述警告而没有进一步的信息。检查构建输出目录,我看到包含所有引用的 DLL,但 VSIX 中缺少所有 Microsoft.VisualStudio.*
DLL,Microsoft.VisualStudio.Shell.Interop.15.3.DesignTime.dll
除外。据我了解互操作程序集,我认为它们是由 VisualStudio 提供的,所以我不必嵌入它们,对吗?
每个引用的引用 属性 Embed Interop Types
都设置为 false。我试图根据我发现的一些建议对其进行更改,但这没有用。我的目标是 .Net 4.6.2。
经过太多个晚上的失败尝试,尤其是错误,我仍然不知道如何解决这个问题。这包括重新安装 NuGet 包、重新启动所有内容、重置实验实例以及逐步删除和重新添加本地 DLL 和 NuGetPackage 的引用。在以前的编辑中,我发布了一个缩短的项目文件内容,但由于输入字符限制,我现在不得不将其删除。相反,这里是 fusionlog 的输出:
=== Zustandsinformationen vor Bindung ===
LOG: DisplayName = Microsoft.VisualStudio.LanguageServices, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/
LOG: Ursprünglicher PrivatePath = NULL
Aufruf von Assembly : MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: Diese Bindung startet im LoadFrom-Load-Kontext.
WRN: Das systemeigene Image wird nicht im LoadFrom-Kontext durchsucht. Das systemeigene Image wird nur im Standard-Load-Kontext durchsucht, z. B. Assembly.Load().
LOG: Die Anwendungskonfigurationsdatei wird verwendet: C:\Users\me\AppData\Local\Microsoft\VisualStudio.0_15d7a44dExp\devenv.exe.config
LOG: Die Hostkonfigurationsdatei wird verwendet:
LOG: Die Computerkonfigurationsdatei von C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config wird verwendet.
LOG: Verweis nach der Richtlinie: Microsoft.VisualStudio.LanguageServices, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PublicAssemblies/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PublicAssemblies/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/Debugger/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/Debugger/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/x86/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/x86/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PublicAssemblies/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PublicAssemblies/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/Debugger/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/Debugger/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/x86/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/Common7/IDE/PrivateAssemblies/DataCollectors/x86/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/USERS/ME/APPDATA/LOCAL/MICROSOFT/VISUALSTUDIO/15.0_15D7A44DEXP/EXTENSIONS/AUTHOR/MY ASSEMBLY/1.0/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/USERS/ME/APPDATA/LOCAL/MICROSOFT/VISUALSTUDIO/15.0_15D7A44DEXP/EXTENSIONS/AUTHOR/MY ASSEMBLY/1.0/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.DLL.
LOG: Download von neuem URL file:///C:/USERS/ME/APPDATA/LOCAL/MICROSOFT/VISUALSTUDIO/15.0_15D7A44DEXP/EXTENSIONS/AUTHOR/MY ASSEMBLY/1.0/Microsoft.VisualStudio.LanguageServices.EXE.
LOG: Download von neuem URL file:///C:/USERS/ME/APPDATA/LOCAL/MICROSOFT/VISUALSTUDIO/15.0_15D7A44DEXP/EXTENSIONS/AUTHOR/MY ASSEMBLY/1.0/Microsoft.VisualStudio.LanguageServices/Microsoft.VisualStudio.LanguageServices.EXE.
您在 this ZIP file 中找到了一个最小的解决方案示例。在这里,我使用新的 VSIX 项目创建了一个新的解决方案,通过向导添加了一个 ToolWindow,添加了我的重要代码,解决了丢失的引用,开始调试并收到了相同的旧 FileNotFoundException
.
有人看到这里的问题吗?提前致谢。
您必须使用 Visual Studio 使用的库版本或更低版本。
对于 Community 2017,可以在
中找到它们C:\Program Files (x86)\Microsoft Visual Studio17\Community\Common7\IDE\CommonExtensions\Microsoft\ManagedLanguages\VBCSharp\LanguageServices
现在 Visual Studio 2017 版本 15.2
Microsoft.CodeAnalysis.Workspaces.dll、Microsoft.VisualStudio.LanguageServices.dll、Microsoft.CodeAnalysis.EditorFeatures.Text 有版本 2.2.0。
因此在 NuGet 中将它们安装或更新到版本 2.2.0 而无需将它们包含到 vsix
您可以通过将 <ForceIncludeInVSIX>true</ForceIncludeInVSIX>
添加到 .csproj 文件来将 Microsoft.VisualStudio.LanguageServices 的较新版本包含在 VSIX 中:
<Reference Include="Microsoft.VisualStudio.LanguageServices, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\packages\Microsoft.VisualStudio.LanguageServices.2.3.1\lib\net46\Microsoft.VisualStudio.LanguageServices.dll</HintPath> <ForceIncludeInVSIX>true</ForceIncludeInVSIX> </Reference>
但随后我们会得到其他错误。
System.InvalidCastException: 'Unable to cast object of type 'Microsoft.VisualStudio.LanguageServices.RoslynVisualStudioWorkspace' to type 'Microsoft.VisualStudio.LanguageServices.VisualStudioWorkspace
Visual Studio2017版本15.3使用2.3.2版本。您的扩展程序使用较低版本 2.2.0 并将在那里工作。如果您将 NuGet 中的组件更新到 2.3.2,扩展将在 15.3 中工作,而在 15.2 中不工作
所以现在使用2.2.0版本
好的,我知道了。
什么都不做,只清理 vsix 项目的 bin
文件夹。其余的都可以正常工作