Printing labels Brother Reference error COM

advertisements

I am having a horrible time with the Brother bpac SDK. I have an application and I am trying to print a label from it. It worked before but I do not know what is wrong now.

Here is the error I am getting: Retrieving the COM class factory for component with CLSID {B940C105-7F01-46FE-BF41-E040B9BDA83D} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

Code:

   'Set up the path and template variables
    Dim path As String = "LabelTemplates\SolutionIDtemplate.lbx"

    'Create the bpac document
    Dim doc As New bpac.Document

    If doc.Open(path) <> False Then

        doc.GetObject("objID").Text = id
        doc.GetObject("objExpDate").Text = expDate
        doc.GetObject("objName").Text = name

        'Print the label
        doc.StartPrint("", bpac.PrintOptionConstants.bpoDefault)
        doc.PrintOut(copies, bpac.PrintOptionConstants.bpoDefault)
        doc.EndPrint()
        doc.Close()

    Else

        MessageBox.Show("Error: " + CStr(doc.ErrorCode))

    End If

NOTE: The class is in the registry and my project is set up to build as a 32 bit application. Everywhere I have looked says to go to Project > Properties > Build Tab > Target CPU = x86. I have done this but the problem still persists. Any help would be much appreciated because I have tried everything that I can think of.

Thanks in advance, Eli


I received the same error on a application i wrote for work when i started using .net 4. That looks like sample code they provide in there SDK. When i changed it to not check for the open path, i was able to get it to work.

Additionally, make sure you have the latest drivers installed with the Bpac printer. This is my altered code.

  Dim path As String = My.Application.Info.DirectoryPath
  Dim doc As New bpac.Document
    doc = CreateObject("bpac.Document")
    doc.SetPrinter(doc.GetPrinterName().ToString, True)

    doc.Open(path + "/TesterLabel.lbx")
    doc.GetObject("objTicket").Text = lstTickets.Items.Item(0).ToString
    doc.GetObject("objTest").Text = issue
    doc.GetObject("objClaim").Text = strIssue
    doc.DoPrint(PrintOptionConstants.bpoDefault, "")
    doc.EndPrint()
    doc.Close()