# C# Label printing with p-Touch Brother Error: System.IO.FileNotFoundException

0

I'm trying to write a program that changes and prints an existing label "label.lbx" from a p-Touch Brother printer. But my program stops at:

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

The error message:

**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).


I have already removed and added the Interop.bpac.dll file. Project cleaned up and rebuilt. Moved the file to the Debug Order. But it didn't help.

Does anyone have an idea why the error message is coming?

My Code:

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
asked on Stack Overflow Nov 25, 2020 by Alex • edited Nov 25, 2020 by Gerhardh

0

I was able to solve the problem. For those who have the problem, try the following. First of all you need the 32 bit version. Then it should work on your computer.

Next you have to pay attention that the dll file is always created with a release. I had to change from "Any CPU" to "x86". And:

Reference --> selection of the dll file in my case (Interop.bpac)--> below in properties: Embed interopt types = False ; Local copy= True

See picture

The code then changes:

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();


Hope this helps some of you and saves you the trouble of troubleshooting.

answered on Stack Overflow Dec 2, 2020 by Alex

User contributions licensed under CC BY-SA 3.0