1. TOMAZ KRALJ
  2. PowerBuilder
  3. Thursday, 20 August 2020 06:17 AM UTC

Hello everyone!

Our company use NiceLabel product for printing labels. Product has option for integration with .NET API. 

I just try to access .NET assembly SDK.NET.dll . I tried with .NET DLL importer but makes to many errors, so result is not usable. As you see on picture PrintEngine namespace and it's functions... are  not imported.

 

Than I tried manual way:

Long ll_return
String ls_dll
string as_path
DotNetAssembly ics_ass
DotNetObject ics_obj


//Specifies a DLL in the relative path

as_path='C:\Program Files\NiceLabel\NiceLabel 2019\bin.net\SDK.NET.dll'

Ls_dll = as_path

//Instantiates the DotNetAssembly object
ics_ass = create DotNetAssembly
ics_obj =create DotNetObject

//Loads the DLL
Ll_return =ics_ass.LoadWithDotNetFramework(ls_dll)

//Checks the result
If ll_return < 0 then
Messagebox("Load "+ls_dll+" Failed", ics_ass.ErrorText)
Return ll_return
End if

 

ll_return = ics_ass.createinstance ("NiceLabel.SDK.PrintEngine", ics_obj)
if ll_return < 0 then
messagebox ("CreateInstance Failed", ics_ass.errortext)
return ll_return
end if


ics_obj.Initialize();


return ll_return

 

/////////////////////////////////////////////////////////////

Problem I have is that code 

ll_return = ics_ass.createinstance ("NiceLabel.SDK.PrintEngine", ics_obj)

returns -1 with error message:

 

This is correct as SDK documentation of .NET assembly said that instance of PrintEngine could not be created and it doesn't have constructor event:

'Main print engine class for accessing all SDK functionality. An instance of PrintEngine class can not be created by the caller. At all times, only one instance of this class will exist in memory, and caller can access it through the Instance property.'

 How to access this instance?

Does anyone know how to solve this or make any workaround?

Tomaz

Mark Lee @Appeon Accepted Answer Pending Moderation
  1. Thursday, 20 August 2020 09:19 AM UTC
  2. PowerBuilder
  3. # 1

Hi Tomaz,

  1. Currently, the PrintEngine class is not be supported because this class could not be created and it doesn't have a constructor event.

          You can refer to the following link for detail:

          https://docs.appeon.com/pb2019r2/powerscript_reference/ch10s97.html#d0e40033

          When you want to use these DLLs in PB, first you need to create an instance of the .NET class and associate it with the DotNetObject object.

          When you use the CreateInstance method, if there is no constructor function that matches the type, the instance will fail to be created.

 

  1. For your issue, you need to wrap a simple class in C# and then use it with .NET DLL importer again.

          You can refer to the code written by another customer in the following link on how to write a wrapper class:

          https://community.appeon.com/index.php/qna/q-a/net-importer-tool#reply-20285 

 

  1. BTW, please refer to the following link for supported data types:

        https://docs.appeon.com/pb2019r2/application_techniques/ch20s01.html

 

Regards,

 

Comment
There are no comments made yet.
TOMAZ KRALJ Accepted Answer Pending Moderation
  1. Thursday, 20 August 2020 11:11 AM UTC
  2. PowerBuilder
  3. # 2

Thanks Mark,

 

Will Appeon make modification on .NET importer tool  to import also classes without constructor event ? Could I ask for enhancement request, where?

Could we see in near future modification on DotNetAssembly and DotNetObject ... to access more features of DotNET?

 

Regards

Tomaz

Comment
  1. Armeen Mazda @Appeon
  2. Thursday, 20 August 2020 14:24 PM UTC
It is not currently scheduled for the next version, so if we do make this enhancement it would be quite some time. Therefore, I recommend you do the workaround Mark mentioned of creating a C# wrapper. Here is an example of how to create such C# wrapper: https://community.appeon.com/index.php/qna/q-a/net-importer-tool#reply-20285
  1. Helpful
  1. Mark Lee @Appeon
  2. Friday, 21 August 2020 07:00 AM UTC
Hi Tomaz,



You can open a Support Ticket ( https://www.appeon.com/standardsupport/newbug ) for this question as an enhancement request of improving the .NET DLL importer tool in PB to meet this requirement. This ticket will then be handled to get this enhancement on Engineer's official ToDo list.



Many thanks in advance!
  1. Helpful
There are no comments made yet.
TOMAZ KRALJ Accepted Answer Pending Moderation
  1. Friday, 21 August 2020 06:27 AM UTC
  2. PowerBuilder
  3. # 3

Hi Mark,

thanks for answer.

I am little disappointed as .NET DLL importer tool was promoted as big new feature in PB 2019, but now we see it has very limited functionality.

I see this tool very useful and I believe that  Appeon will work on it to make it work as we as customers want to.

 

Regards

Tomaz

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.