Search code examples
c#zebra-printerscomobjectinteropservices

Zebra Printer: System.Runtime.InteropServices.COMException (0x8004FFFF)


We use the following code to print to a card.

byte[] image;

ZXPPRINTERLib.Job job = new ZXPPRINTERLib.Job();
job.JobControl.Destination = DestinationTypeEnum.Eject;

using (ZMotifGraphics graphics = new ZMotifGraphics())
{
    graphics.InitGraphics(0, 0, ZMotifGraphics.ImageOrientationEnum.Landscape, ZMotifGraphics.RibbonTypeEnum.MonoK);
    graphics.ColorProfile = string.Empty;
    graphics.DrawTextString(...);

    int imageSize;
    image = graphics.CreateBitmap(out imageSize);
}

int actionId;
job.BuildGraphicsLayers(SideEnum.Front, PrintTypeEnum.MonoK, GraphicTypeEnum.BMP, image);
job.PrintGraphicsLayers(1, out actionId);

It works on our development machines, but when we move to another test environment, we get the following error:

System.Runtime.InteropServices.COMException (0x8004FFFF): PrintGraphicsLayers Failed (65535) - Image processing error.
    at ZXPPRINTERLib.IJob.PrintGraphicsLayers(Int32 copies, Int32& actionID)

Solution

  • It appears the problem is caused by the manner in which the ZXPPrinter.dll is registered.

    As Hans points out in this thread, when registering both the 32-bit and 64-bit versions of the dll a folder with the ZXP3Raster.dll and a bunch of text files are created under C:\ProgramData\ZXP Series Card Printer SDK\.

    Registering both versions of the dll, will cause the first to be overwritten.

    Furthermore, my C# project's build Platform Target was set to build as Any CPU. The project ended up running as a 64-bit application, whilst referencing the 32-bit ZXPPrinter.dll.