【问题标题】:C# Label printing with p-Touch Brother Error: System.IO.FileNotFoundException使用 p-Touch Brother 错误打印 C# 标签:System.IO.FileNotFoundException
【发布时间】:2020-11-25 08:35:33
【问题描述】:

我正在尝试编写一个程序来更改和打印来自 p-Touch Brother 打印机的现有标签“label.lbx”。 但我的程序停在:

bpac.Document doc = new bpac.Document();

错误信息:

**System.IO.FileNotFoundException:** "The COM class directory for the component with CLSID {B940C105-7F01-46FE-BF41-E040B9BDA83D} could not be retrieved due to the following error: 8007007e The specified module was not found. (HRESULT exception: 0x8007007E).

我已经删除并添加了 Interop.bpac.dll 文件。项目清理和重建。将文件移至调试顺序。但这没有帮助。

有人知道为什么会出现错误消息吗?

我的代码:

string path = @"C:\Users\source\repos\LabelTool\label.lbx";

bpac.Document doc = new bpac.Document();

doc.Open(path);
doc.SetPrinter("Printer", true);

doc.GetObject("ReplacePlace").Text = textBox1.Text;

doc.StartPrint("", bpac.PrintOptionConstants.bpoDefault);
doc.PrintOut(1, bpac.PrintOptionConstants.bpoDefault);
doc.EndPrint();
doc.Close();

【问题讨论】:

    标签: c# system


    【解决方案1】:

    我能够解决问题。对于那些有问题的人,请尝试以下方法。 首先,您需要 32 位版本。然后它应该可以在您的计算机上运行。

    接下来你要注意 dll 文件总是随发行版一起创建的。 我不得不从“任何 CPU”更改为“x86”。并且:

    参考 --> 在我的例子中选择 dll 文件 (Interop.bpac)--> 下面的属性:嵌入 interopt types = False ;本地副本=真

    See picture

    然后代码发生变化:

    using bpac;
    ...
    
    string path = @"C:\Users\source\repos\LabelTool\label.lbx";
    
    
    bpac.Document doc = new bpac.Document();
    
    doc.Open(path);
    doc.SetPrinter("Printer", true);
    
    doc.GetObject("ReplacePlace").Text = textBox1.Text;
    
    doc.StartPrint("", bpac.PrintOptionConstants.bpoDefault);
    doc.PrintOut(1, bpac.PrintOptionConstants.bpoDefault);
    doc.EndPrint();
    doc.Close();
    

    希望这对你们中的一些人有所帮助,并为您省去故障排除的麻烦。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-08-26
      • 1970-01-01
      • 2014-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多