scottplot 创建组件“formplot”失败和错误汇总

我的解决办法,回退scottplot.winform的版本为4.1.36就成功啦

在这里插入图片描述

在尝试创建组件“FormsPlot”时,遇到了以下详细的错误链:

主要异常:System.TypeInitializationException,指出ScottPlot.Fonts的类型初始值设定项引发了异常。
内部异常一:System.TypeInitializationException,进一步指出SkiaSharp.SKTypeface的类型初始值设定项也引发了异常。
最底层异常:System.DllNotFoundException,具体错误为“Unable to load library ‘libSkiaSharp’”,表明无法加载名为libSkiaSharp的库文件。
错误堆栈跟踪显示,问题发生在多个库和类的初始化过程中,具体路径和行号如下:

在SkiaSharp.LibraryLoader.LoadLocalLibrary(string libraryName),位于/mnt/vss/_work/1/s/binding/Binding.Shared/LibraryLoader.cs的第38行。
在SkiaSharp.SkiaApi.sk_typeface_ref_default(),位于/mnt/vss/_work/1/s/binding/Binding/SkiaApi.Generated.cs的第12888行。
在SkiaSharp.SKTypeface的静态构造函数中,位于/mnt/vss/_work/1/s/binding/Binding/SKTypeface.cs的第26行。
此外,还涉及ScottPlot库中的多个组件,包括FontResolvers.SystemFontResolver.InstalledSansFont()、Fonts的静态构造函数、LabelStyle的静态构造函数、Plottables.Benchmark的静态构造函数、Plot的静态构造函数,以及WinForms.FormsPlotBase和WinForms.FormsPlot的静态构造函数。

这些错误提示开发者需要检查SkiaSharp库是否已正确安装并配置在项目中,以及ScottPlot库是否依赖于特定版本的SkiaSharp或其他必要的库文件。同时,确保所有相关的DLL文件都已正确放置在项目的输出目录中,或者已添加到系统的PATH环境变量中,以便程序能够找到并加载它们。

2、发生了新的错误

System.IO.FileLoadException
HResult=0x80131040
Message=未能加载文件或程序集“ScottPlot, Version=5.0.40.0, Culture=neutral, PublicKeyToken=86698dc10387c39e”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)
Source=ScottPlot.WinForms
StackTrace:
在 ScottPlot.FormsPlot…ctor()
在 hopesuccess.Form1.InitializeComponent() 在 F:\thorlab\VISA\WinNT\WFS\Examples\MS VS CSharp Demo\hopesuccess\Form1.Designer.cs 中: 第 39 行
在 hopesuccess.Form1…ctor() 在 F:\thorlab\VISA\WinNT\WFS\Examples\MS VS CSharp Demo\hopesuccess\Form1.cs 中: 第 18 行
在 hopesuccess.Program.Main() 在 F:\thorlab\VISA\WinNT\WFS\Examples\MS VS CSharp Demo\hopesuccess\Program.cs 中: 第 19 行

内部异常 1:
FileLoadException: 未能加载文件或程序集“ScottPlot, Version=4.1.36.0, Culture=neutral, PublicKeyToken=86698dc10387c39e”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)

方法

检查配置文件
确保项目的配置文件(如 app.config 或 web.config)中没有错误的绑定重定向。

检查 app.config
打开 app.config 文件,查找 节点下的 部分,确保没有错误的绑定重定向:

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="ScottPlot" publicKeyToken="86698dc10387c39e" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.40.0" newVersion="5.0.40.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

然后重新改一下app.config这个文件可以了
您提供的 app.config 文件中有一个绑定重定向,将 ScottPlot 的旧版本重定向到了 5.0.40.0 版本。这可能是导致问题的原因之一,因为您希望使用 4.1.60 版本。我们需要修改绑定重定向,使其指向 4.1.60 版本。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
    </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="ScottPlot" publicKeyToken="86698dc10387c39e" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.60.0" newVersion="4.1.60.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="ScottPlot.WinForms" publicKeyToken="86698dc10387c39e" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.60.0" newVersion="4.1.60.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值