Jump to content

.NET: Citizen.LayoutUtilities.Printing - Controller.Open() open fails


Recommended Posts

Hi guys,

maybe you can help me there with an .NET issue.
I try to use the Controller.Open() method from the Citizen.LayoutUtilities.Printing, but it always reports -1 as an error.
There is no LabVIEW error on the constructor or invoke node and the c# example works fine.

2020-11-27_14-52-44_Untitled_1_Block_Diagram_.png.e6d3d0895d92ebc756e941bed37efe54.png

This is the Citizen SDK with the manual and examples:
https://www.citizen-systems.co.jp/en/printer/download/sdk-layout/sdk-layout-windriver_V1400E.zip

 

There are also c# examples included in the SDK which work without problems with the same path/file.

2020-11-27_14-54-03_TestPrint_(Sample).png.e02005e0f2807fe10bad922722323c76.png

 

The call as well as the sample code looks not that complicated, not sure what is causing the problem.

2020-11-27_14-53-28_Windows_Layout_SDK_Programming_Manual_-_Adobe_Acro.png.32b115940d10d83764cef23dbc101079.png2020-11-27_14-53-38_Windows_Layout_SDK_Programming_Manual_-_Adobe_Acro.png.46064b525bc6be7b0eb228cc85096ea7.png2020-11-27_14-53-56_CUsersMichael.UrayDownloadsCitizenSDKsdk-la.png.8b11b7436b49f2a9cfb56ecf8c6d9b91.png2020-11-27_14-59-58_Windows_Layout_SDK_Programming_Manual_-_Adobe_Acro.png.8de0819b19dbaf7a455b7ddc0cfc9d88.png

 

 

I did notice also another strange behaviour with the DLL selection of the constructor.

Adding contructor, choosing DLL the first time:

 

2020-11-27_15-14-18_Mozilla_Firefox.png.8f1bf1109fa9b9690cc27a2bcea818a5.png

2020-11-27_15-14-26_Untitled_1_Block_Diagram.png.602140c83103da2e89f39d583495db9c.png

 

If I choose the DLL the first time, then the constructor node seems not to to be refering to the DLL.
It's empty and property and invoke nodes do not show anything.

2020-11-27_15-14-33_Untitled_1_Block_Diagram_.png.513d96053cf37e491daafaec50321eef.png
I have to chose then again "Select Constructor..." and select the according DLL again, then I can access invoke and property nodes by the constructor reference without problems.

2020-11-27_15-14-49_Mozilla_Firefox.png.3a0b35bf2c3e2cfee3094cbb5e065d8d.png

2020-11-27_15-14-54_Untitled_1_Block_Diagram_.png.7dec08c11300d5001ee83b9ef5174f2b.png

The second time it works and the node is reffering to the DLL.

2020-11-27_15-15-33_Untitled_1_Block_Diagram_.png.75dee0c1d4600f29defc4db6491174e1.png

I tried it with LabVIEW 2013 as well as with 2020.
Any idea what could be wrong?

2020-11-27_14-59-33_print.png

Edited by Michael Uray
Link to post
Share on other sites
  • Michael Uray changed the title to .NET: Citizen.LayoutUtilities.Printing - Controller.Open() open fails

Sure, this is the printer driver, the printer is connected via RS232:
https://www.citizen-systems.co.jp/en/printer/download/driver-windows-en/pmu2xxxiiip_v3501E.zip

This is the SDK with documentation and examples:
https://www.citizen-systems.co.jp/en/printer/download/sdk-layout/sdk-layout-windriver_V1400E.zip

I wanted to re-create the "sdk-layout-windriver\Sample_WinLayoutSDKviaPrinterDriver_en\VCS2010\Sample1" in LabVIEW.
1713200268_CitizenPrinterTest.png.6bec3cc47475e43c348d6967eb6a6399.png

It already fails at the "Open()", even the file exists and the file works with the "Sample1" software which came with the SDK.

There is a strange behaviour with the constructor node, I have to select the according DLL files 2 times that the constructor gets valid.

Edited by Michael Uray
Link to post
Share on other sites

You should check that both the DLL and LV have the same bitness, 32 bits or 64 bits, not mixed.

You might be able to bypass the entire problem, if you can create a raw printer file.

1. Create a raw file - usually label printers use a text based encoding (for example, Zebra printers use ZPL, other vendors have similar formats). This will be your template file.

2. If you are using Windows, create a printer share.

3. Set the fields in the template.

4. copy the file to the share - using the system call, issue a copy <filename> \\localhost\<share name> command.

 

Link to post
Share on other sites

It shows me it is valid for both platforms.
2020-11-27_18-47-19_ILSpy.png.401597af9b49e8e8a52bf97180e62342.png

There is a utility with it to create these .CLF template files which I want to use and where the user can change the layout later, content data should get populated into it by LabVIEW.
I run into an error just loading this template file without adding any data to it.

2020-11-27_18-48-28_Layout1.CLF_-_Layout_Editor.png.273a4fdd76710cf7dca76ad91204591b.png

Link to post
Share on other sites

There is something strange about how this library is managed. For some reason it seems to work if the VI is part of a project, but not as a standalone VI.

Standalone

image.png.20bd2e76734650b99d57c476c5c2f364.png

As part of a project

image.png.eec00ff46f9827e8d754349e090cadca.png

I did not reproduce the entire example, so it might fail. At least you can try adding your VI to a project and see if it works (make sure the assembly is listed under Dependencies).

Edited by LogMAN
  • Thanks 2
Link to post
Share on other sites

Thanks guys, i missed that with the assembly location.
https://zone.ni.com/reference/en-XX/help/371361R-01/lvconcepts/net_defaults/

2020-11-27_19-22-22.png.83e28170664828d2ab4ca5bb9b39b97b.png

If I add the vi to a project, then it shows there up as dependency and the VI works properly.
I noticed that I have to open the project first and then the VI and not the other way around.

2020-11-27_19-23-56.png.ee89155c5876fe5c682a723e9f7e29e4.png

It also works fine if i put the DLLs into the LabVIEW.exe directory.

Thanks again for your help.

Edited by Michael Uray
Link to post
Share on other sites

Edit: Nevermind, I misread your post 😄

21 minutes ago, Gribo said:

What is the difference between these two methods? If a .NET library is included in a project, does LV load it before the VI is run?

In order for LabVIEW to know about all dependencies in a project, it has to traverse all its members. Because this operation is slow, it probably keeps references open for as long as possible. I'm not sure why it would unload the assembly in standalone, but that is how it is.

Edited by LogMAN
Link to post
Share on other sites

I had to add the files then manually to the project that they also get packed into the application builder setup / bult directory.
I think the easiest way ist to add all the files to an folder an to add then the folder to auto-populating to the project.
2020-11-28_02-18-24__Thermal_Cam.lvproj_-_Project_Explorer.png.422922f974c47ba5a454ddb5ae37cb5f.png

2020-11-28_02-15-26__Thermal_Cam.lvproj__-_Project_Explorer.png.d7e55ab220e27e48fe346b783fb12591.png

Then all the files will automatically show up in the data folder of the built directory.

2020-11-28_02-19-15_data.png.678467733c4549215040f6e91d8e2e8a.png

 

Edited by Michael Uray
Link to post
Share on other sites

Make sure that you have the rights to distribute those binaries before you put them in your build specification. There is a license agreement that you accepted when you installed them on your machine.

Note that you don't have to distribute those assemblies yourself. Perhaps there is a runtime installer available which your clients can use. As long as the assemblies are installed on the target machine, LabVIEW will either locate them automatically, or you can specify the location in an application configuration file.

Here are some resources on how assemblies are located:

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.