报错:- $exception {"未能加载文件或程序集“Seagull.BarTender.Print, Version=11.0.8.1, Culture=neutral, PublicKeyToken=109ff779a1b4cbc7”或它的某一个依赖项。试图加载格式不正确的程序。"} System.BadImageFormatException
原因是:.NET Framework目标框架版本太高,默认vc是4.7,改成4.0后故障解决下面是解决步骤
解决方法:
1.解决方案属性
2.目标框架改成.NET Framework 4
3.调试OK
VB.Net代码示例
Imports Seagull.BarTender.Print
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' '初始化一个新的BarTender打印引擎
Using btEngine As New Engine(True)
' 启动BarTender打印引擎。
btEngine.Start()
' Open a format document.打开一个格式化文档。
Dim btFormat As LabelFormatDocument = btEngine.Documents.Open("C:\Users\Administrator\Desktop\202303019_test.btw")
' Print the format document.打印格式化文档
Dim nResult As Result = btFormat.Print()
' Display the print result.显示打印结果。0=成功
Console.WriteLine("Print status = " & nResult)
' Close the current format without saving.关闭当前格式而不保存
btFormat.Close(SaveOptions.DoNotSaveChanges)
' Stop the BarTender print engine.停止BarTender打印引擎
btEngine.Stop()
End Using
End Sub
End Class