You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

DYMO标签打印报错:SkiaSharp.Views.Desktop程序集加载失败求助

解决DYMO标签打印中SkiaSharp.Views.Desktop程序集版本不匹配问题

运行DYMO标签打印代码时抛出System.IO.FileLoadException,错误信息:

$exception {"Could not load file or assembly 'SkiaSharp.Views.Desktop, Version=1.68.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies. The specified assembly manifest definition does not match the assembly reference. ( Exception from HRESULT: 0x80131040)":"SkiaSharp.Views.Desktop, Version=1.68.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756"} System.IO.FileLoadException

开发环境:Visual Studio 2022社区版,.NET Framework 4.8,VB.NET代码如下:

Imports DymoSDK.Implementations
Imports System.IO.Path
Imports DymoSDK
Imports OpenTK
Module Module1

    Sub Main()
        DymoSDK.App.Init()

        Dim fullpath As String = System.IO.Path.GetFullPath("C:\Users\fabri\source\repos\VB_DYMOSDK_Sample\VB_DYMOSDK_Sample\ProvaEtichetta.dymo")
        Dim dymoSDKLabel = DymoLabel.Instance
        dymoSDKLabel.LoadLabelFromFilePath(fullpath)

        Dim dymoSDKPrinter = DymoPrinter.Instance

        Dim Printers = DymoPrinter.Instance.GetPrinters()
        Dim ConnectedPrinter = Printers.FirstOrDefault()

        For Each prt In Printers    ' Iterate through each element and find a connected printer.  
            Console.WriteLine($"Printer info: {prt.DriverName}, {prt.Name}, {prt.IsTwinTurbo}")
            If prt.IsConnected Then
                ConnectedPrinter = prt
            End If
        Next

        If dymoSDKPrinter.PrintLabel(dymoSDKLabel, ConnectedPrinter.Name, 1, False, False, 0, False, False) Then
            Console.WriteLine("Print successful.")
        End If

        Console.ReadKey()

    End Sub

End Module

解决步骤

  • 确认已安装的SkiaSharp包版本
    打开Visual Studio的NuGet包管理器,查看项目中SkiaSharp和SkiaSharp.Views.Desktop的版本。DYMO SDK依赖1.68.0.0版本,若当前版本不符,会引发版本不匹配错误。

  • 安装指定版本的SkiaSharp包
    在NuGet包管理器控制台执行以下命令,强制安装1.68.0版本的包:

    Install-Package SkiaSharp -Version 1.68.0
    Install-Package SkiaSharp.Views.Desktop -Version 1.68.0
    
  • 添加程序集绑定重定向
    若安装指定版本后仍报错,在项目的App.config中添加绑定重定向配置,强制应用使用正确版本:

    <configuration>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="SkiaSharp.Views.Desktop" publicKeyToken="0738eb9f132ed756" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-1.68.0.0" newVersion="1.68.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="SkiaSharp" publicKeyToken="0738eb9f132ed756" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-1.68.0.0" newVersion="1.68.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    </configuration>
    
  • 清理并重新生成项目
    执行以下操作确保引用生效:

    1. 右键项目 → 清理
    2. 右键项目 → 重新生成
    3. 删除项目目录下的bin和obj文件夹后再次重新生成
  • 验证DYMO SDK依赖
    检查DYMO SDK安装目录(通常为C:\Program Files\DYMO\DYMO Label Software\SDK)下的SkiaSharp.Views.Desktop.dll版本,确保与项目引用版本一致。若不一致,手动将SDK目录下的dll复制到项目输出目录覆盖。

内容的提问来源于stack exchange,提问作者BBGMetalmeccanica BBG

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 01:17:32