Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP forum
Answered

.Net Assembly Error in Dexterity Dictionary - Unknown Method

Posted on by 59

I have worked with Dexterity for a while, but I'm just now trying to work with external .NET assemblies and I'm running into an error which is probably basic lack of understanding.

I am trying to build Zebra label printing directly into my Dexterity dictionary using the Zebra SdkApi.Core.dll assembly (latest version). I have added the .Net Assembly to the dictionary in the libraries section and it looks like I am able to reference the namespace, objects and some procedures. I am running into an issue with a specific procedure, and dexterity only says Unknown Method: "Write". I'm adding the very basic test procedure below, and I'm not sure if there's a special way I need to reference Objects which inherit other objects.

using Zebra.Sdk.Comm;
using System;
using System.Text;

local Connection printerConn;
local text PrintLabel;

printerConn = new TcpConnection("PrinterAddress", TcpConnection.DEFAULT_ZPL_TCP_PORT);{address, port}
PrintLabel="^XA^FO20,20^A0N,25,25^FDThis is a ZPL test.^FS^XZ";

printerConn.Open();
printerConn.Write(Encoding.UTF8.GetBytes(PrintLabel));
printerConn.Close();

Dex only flags the Write line with "Unknown method: 'Write' ". I have tried reading and writing to other properties and can access other basic methods.

Write has 3 overloads, but this is the most basic. All of them fail though.

Connection (interface) and TcpConnection (class) are members of Zebra.Sdk.Comm.

This is based on the example C# app here https://techdocs.zebra.com/link-os/2-15/pc_net/

I'll keep plugging away, but hopefully someone can point me in the right direction.

Thanks!

  • Midmichael Profile Picture
    Midmichael 59 on at
    RE: .Net Assembly Error in Dexterity Dictionary - Unknown Method

    Thanks David, this gives me several different options to try since the library option at this point seems to be a no-go. I appreciate the help.

  • Verified answer
    David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,835 Moderator on at
    RE: .Net Assembly Error in Dexterity Dictionary - Unknown Method

    Hi Chris

    If you went down the report path, it would need to be a text report with the appropriate information on it to generate the label as desired.

    Another path is using Crystal Reports, or SSRS to generate the report.

    OR......

    Create a Dexterity placeholder function with the parameters needed, then create a VSTools Addin which has an event after the function and then have your .Net code in the Addin rather than in Dexterity.  This method works for all versions of GP from v9 onwards and not just the later versions which have the .Net Interop.  This is the method I use for my .Net code in GP Power Tools.

    David

  • Midmichael Profile Picture
    Midmichael 59 on at
    RE: .Net Assembly Error in Dexterity Dictionary - Unknown Method

    I tried string without any success. I suspect the issue may lie in the Write procedure which is expecting a Byte array. Is there a way to generate a byte array in dexterity and then pass it into the Write?

    I tried this method because honestly, it seemed like a simple approach (in theory). I have previously created windows mobile apps which write the labels to the printers directly over TCP, and thought this would work the same. I already have a printer label in ZPL code designed, it contains a QR code for scanners, among other fields which need to me populated from GP tables.

    How do I pass a ZPL string/text to a named printer? Would this need to be created as a text report with the ZPL language and the GP fields inserted?

  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,835 Moderator on at
    RE: .Net Assembly Error in Dexterity Dictionary - Unknown Method

    Hi Chris

    I think that the problem might be the data type for PrintLabel.  You have it declared as a Dexterity text datatype.  Maybe you should be declaring it to System.String instead.

    Can I ask why you don't just print to the label printer using a standard printer driver. You can use named printers to direct the print job. Integrating with Named Printers is simple... I know.... I created it. back in v3.00 before Great Plains Software purchased it for v5.5 and added it to core code for v6.0.

  • Midmichael Profile Picture
    Midmichael 59 on at
    RE: .Net Assembly Error in Dexterity Dictionary - Unknown Method

    Hi David, thanks for the response. I have added SdkApi.Core which is the zebra dll that contains Comm, Printer  and a multitude of other classes.

    I added a screenshot below. In the script, if I comment out the using Zebra.Sdk.Comm, it does fail at the creation of the printerConn object which leads me to believe it is seeing and accessing the library.

    GP-Libraries.jpg

  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,835 Moderator on at
    RE: .Net Assembly Error in Dexterity Dictionary - Unknown Method

    Dumb question:

    Did you add Zebra.Sdk.Comm as a library?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,554 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,588 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Product updates

Dynamics 365 release plans