4

我已将 DYMO 280 标签打印机连接到我的电脑并尝试从我的 C# .NET winforms 应用程序打印标签,但我遇到了一些关于 XML 标签的错误。

我正在使用 DYMO Label v8.0 创建标签模板。你能给我一些代码示例吗?我发现的大多数例子都已经过时了(从 2011 年到 2011 年)。

我已经DYMO.Label从 NuGet 包安装并将.label文件移动到我的源代码中。
下面是我尝试打印标签的代码:

var label = Label.Open(AppDomain.CurrentDomain.BaseDirectory + "data\\elsis.label");
label.SetObjectText("productCode", productCode);
label.SetObjectText("productPrice", productPrice);
label.Print("DYMO LabelManager 280");
</StackTrace><ExceptionString>System.Xml.Schema.XmlSchemaValidationException: The element 'TextObject' has invalid child element 'GroupID'. List of possible elements expected: 'HorizontalAlignment'.</ExceptionString></InnerException></InnerException></Exception></TraceRecord>
Exception thrown: 'DYMO.DLS.Runtime.DlsRuntimeException' in DYMO.DLS.Runtime.dll
An unhandled exception of type 'DYMO.DLS.Runtime.DlsRuntimeException' occurred in DYMO.DLS.Runtime.dll
Unable to load label template 'C:\Users\armav\source\repos\Elesis\Elesis\bin\Debug\data\elsis.label'
4

1 回答 1

0

这是一个老问题,但如果其他人有这个问题,我在提供的 C# 示例中遇到了这个问题。

原因是 .dll 文件没有复制到 bin 中(即使我的 PC 上安装了软件)一旦我复制了 dymo 框架 DLL(Interop.DYMOBarcodeLib.dll),它就可以工作了。

于 2021-12-11T08:53:46.917 回答