gpt4 book ai didi

c# - Visual Studio 扩展找不到所需的程序集

转载 作者:太空狗 更新时间:2023-10-29 22:58:25 25 4
gpt4 key购买 nike

我为 Visual Studio 2013 编写了一个扩展。因为 bloody ComboBox bug ,我必须将 System.Windows.Interactivity 包含到我的项目中。要添加更多详细信息:

  1. 使用额外的解决方案程序集,例如 .Editor,其中包含物理编辑器。
  2. .Editor 引用 System.Windows.Interactivity
  3. 也引用了 System.Windows.Interactivity。事实上,我正在使用 nuget 加载 Expression.Blend.Sdk 包(它与 WPF 4.5 兼容)

效果:当包含提到的ComboBox的部分编辑器显示时,我立即得到一个异常:

A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

Additional information: Could not load file or assembly 'System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

我在实验实例和文件夹中运行扩展:

C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\12.0Exp\Extensions\<Company>\<Extension>\1.0

包含 System.Windows.Interactivity.dll,但由于某种原因,IDE 似乎看不到它。

更奇怪的是,我正在使用其他附加包,如 IronPython,它们从来没有给我带来这样的麻烦。

我该如何解决?


编辑:回应评论

实际上,InnerException 包含名为 FusionLog 的字段,其中包含以下内容:

=== Pre-bind state information ===
LOG: DisplayName = System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35 | Domain ID: 1
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\<user>\AppData\Local\Temp\devE4FC.tmp
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PublicAssemblies/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PublicAssemblies/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Platform/Debugger/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Platform/Debugger/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PublicAssemblies/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PublicAssemblies/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Platform/Debugger/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Platform/Debugger/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Windows.Interactivity/System.Windows.Interactivity.EXE.

但还有更多。我使用 ProcMon 检查,Visual Studio 在哪里查找该 DLL 并最终注意到:

08:46:46,7508050    devenv.exe  7544    CreateFile  C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\12.0Exp\Extensions\<Company>\<Extension>\1.0\Lib\System.Windows.Interactivity  NAME NOT FOUND  Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
08:46:46,7509231 devenv.exe 7544 CreateFile C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\12.0Exp\Extensions\<Company>\<Extension>\1.0\Lib\System.Windows.Interactivity.EXE NAME NOT FOUND Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
08:46:46,7510379 devenv.exe 7544 CreateFile C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\12.0Exp\Extensions\<Company>\<Extension>\1.0\Lib\System.Windows.Interactivity.DLL NAME NOT FOUND Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

Lib 文件夹包含一些我正在使用的 Python 模块(出于脚本目的,因为我正在使用 IronPython)。而且,具有讽刺意味的是,程序集在

C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\12.0Exp\Extensions\<Company>\<Extension>\1.0\

文件夹(没有 Lib)。但是 Visual Studio 在搜索中忽略了它,尽管事实上它是最自然的搜索位置(因为请求程序集也驻留在那里)

最佳答案

这是解决此问题的方法。我不喜欢它,但它有效:)

解决方案是从源代码中强制加载程序集,这样 PresentationFramework 就不必在解析 XAML 文件时寻找它。例如:

private static void LoadSystemWindowsInteractivity()
{
// HACK: Force load System.Windows.Interactivity.dll from plugin's
// directory
typeof(System.Windows.Interactivity.Behavior).ToString();
}

static MyEditorFactory()
{
LoadSystemWindowsInteractivity();
}

关于c# - Visual Studio 扩展找不到所需的程序集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29362125/

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