【问题标题】:Using OxyPlot in Visual Studio debugger extension在 Visual Studio 调试器扩展中使用 OxyPlot
【发布时间】:2017-09-18 06:41:44
【问题描述】:

我正在尝试在 VS 调试器扩展 (WPF Xaml UserControl) 中使用 OxyPlot 库,但是,即使是最简单的示例也失败了。在控件构造函数中调用 InitializeComponent 会抛出如下异常:

System.Windows.Markup.XamlParseException occurred
HResult=0x80131501
Message=Could not load file or assembly 'OxyPlot.Wpf, PublicKeyToken=75e952ba404cdbb0' or one of its dependencies. The system cannot find the file specified.
Source=PresentationFramework
StackTrace:
 at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
 at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
 at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
 at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
 at GraphicalDebugging.PlotWatchControl.InitializeComponent() in C:\code\git\temp\graphical-debugging\Visual_Studio_2015\GraphicalDebugging\PlotWatchControl.xaml:line 1
 at GraphicalDebugging.PlotWatchControl..ctor() in C:\code\git\temp\graphical-debugging\Visual_Studio_2015\GraphicalDebugging\PlotWatchControl.xaml.cs:line 29
 at GraphicalDebugging.PlotWatch..ctor() in C:\code\git\temp\graphical-debugging\Visual_Studio_2015\GraphicalDebugging\PlotWatch.cs:line 37
Inner Exception 1:
FileNotFoundException: Could not load file or assembly 'OxyPlot.Wpf, PublicKeyToken=75e952ba404cdbb0' or one of its dependencies. The system cannot find the file specified.

OxyPlot 程序集正确包含在扩展部署文件夹中。 OxyPlot 的示例应用程序都可以正常工作,因此它似乎与 VS 调试器扩展以及如何解析程序集有关。

XAML 命名空间声明是:

xmlns:oxy="clr-namespace:OxyPlot.Wpf;assembly=OxyPlot.Wpf"

而在一些 (XAML) 示例中,我还看到:

xmlns:oxy="http://oxyplot.org/wpf"

该 URL 解析为 404,并尝试编译我得到:

error MC3074: The tag 'PlotView' does not exist in XML namespace 'http://oxyplot.org/wpf'. 

但是,OxyPlot 包中的 WPF 示例使用相同的命名空间声明没有问题?

更新:问题的融合日志,很明显,程序集加载器找不到 OxyPlot.Wpf.dll,尽管 DLL 在安装的 VS 扩展的位置(在 C:\Users\\AppData\ Local\Microsoft\VisualStudio\14.0Exp\Extensions\Adam Wulkiewicz\GraphicalDebugging\0.7):

*** Assembly Binder Log Entry  (2017-09-19 @ 08:46:44) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = OxyPlot.Wpf, PublicKeyToken=75e952ba404cdbb0
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: OxyPlot.Wpf, PublicKeyToken=75e952ba404cdbb0 | 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 14.0/Common7/IDE/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = devenv.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\robi\AppData\Local\Temp\dev7ED0.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 14.0/Common7/IDE/OxyPlot.Wpf.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/OxyPlot.Wpf/OxyPlot.Wpf.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PublicAssemblies/OxyPlot.Wpf.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PublicAssemblies/OxyPlot.Wpf/OxyPlot.Wpf.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/OxyPlot.Wpf.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/OxyPlot.Wpf/OxyPlot.Wpf.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/OxyPlot.Wpf.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/OxyPlot.Wpf/OxyPlot.Wpf.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Platform/Debugger/OxyPlot.Wpf.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Platform/Debugger/OxyPlot.Wpf/OxyPlot.Wpf.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/OxyPlot.Wpf.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/OxyPlot.Wpf/OxyPlot.Wpf.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/DataCollectors/OxyPlot.Wpf.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/DataCollectors/OxyPlot.Wpf/OxyPlot.Wpf.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/OxyPlot.Wpf.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/OxyPlot.Wpf/OxyPlot.Wpf.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/OxyPlot.Wpf.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/OxyPlot.Wpf/OxyPlot.Wpf.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PublicAssemblies/OxyPlot.Wpf.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PublicAssemblies/OxyPlot.Wpf/OxyPlot.Wpf.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/OxyPlot.Wpf.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/OxyPlot.Wpf/OxyPlot.Wpf.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/OxyPlot.Wpf.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/OxyPlot.Wpf/OxyPlot.Wpf.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Platform/Debugger/OxyPlot.Wpf.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Platform/Debugger/OxyPlot.Wpf/OxyPlot.Wpf.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/OxyPlot.Wpf.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/OxyPlot.Wpf/OxyPlot.Wpf.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/DataCollectors/OxyPlot.Wpf.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/DataCollectors/OxyPlot.Wpf/OxyPlot.Wpf.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/OxyPlot.Wpf.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/OxyPlot.Wpf/OxyPlot.Wpf.EXE.
LOG: All probing URLs attempted and failed.

想法?

【问题讨论】:

  • 我正在使用 http:// 命名空间的方式,它适用于我。您使用的是哪个 oxyplot 版本?
  • 2.0.0-unstable1013 版本(通过 Nuget)
  • OxyPlot.Core 也是 2.0.0-unstable1013
  • 我对 OxyPlot.Wpf 包(2.0.0-unstable1013)使用相同的版本,对 OxyPlot.Core 使用 v2015.1.708-alpha。都通过 NuGet。
  • 您是否尝试过添加 AssemblyResolve 挂钩? AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(ResolveAssembly);

标签: c# visual-studio oxyplot


【解决方案1】:

好的,我不是一个精通 .NET 的人,我感谢 Palle Due 的解决方案,在我添加的扩展包构造函数中:

AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

然后在处理程序中:

private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
    return AppDomain.CurrentDomain.Load(args.Name);
}

它很好地加载了 OxyPlot。唷。

【讨论】:

  • 我不明白。我应该把这段代码放在哪里?在 oxyplot.wpf 库的某个地方?或者在我创建的程序中的某个地方?
  • 在您创建的程序中。
  • 还是不行。我把上面的代码放在MainWindow类的构造函数中。如果我现在运行代码并在“return AppDomain.CurrentDomain.Load(args.Name);”上放置一个断点线。 args.Name 不会改变。 args.Name 变量每次都是“MyApplication.resources, Version=1.0.0.0, Culture=en-US, PublicKeyToken=null”,直到我得到一个stackoverflow。
猜你喜欢
  • 1970-01-01
  • 2011-03-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-06
  • 1970-01-01
  • 2011-03-11
相关资源
最近更新 更多