1. Arcady Abramov
  2. PowerBuilder
  3. Saturday, 11 April 2020 13:31 PM UTC

Hello, support

Can you provide an example of accessing nested classes in PB as this help text explains.

I failed to do it in either code or debugger.

Thank you

Arcady

Accepted Answer
Ricardo Jasso Accepted Answer Pending Moderation
  1. Saturday, 11 April 2020 19:38 PM UTC
  2. PowerBuilder
  3. # Permalink

Arcady,

This is an example of how to access a nested class (Class2 is declared inside Class1):

DotNetAssembly ldn_assembly
ldn_assembly = Create DotNetAssembly

Long ll_return
ll_return = ldn_assembly.LoadWithDotNetFrameWork("...\Test.dll")

DotNetObject ldn_object
ldn_object = Create DotNetObject

ll_return = ldn_assembly.CreateInstance ("Test.Class1+Class2", ldn_object)

Regards,

Ricardo

 

Comment
  1. Ricardo Jasso
  2. Saturday, 11 April 2020 19:43 PM UTC
This is the Visual Basic.NET code I used to define the main class and the nested class:



Public Class Class1



Property Prop1 As Integer

Property Prop2 As String



' Nested class

Public Class Class2

Property Prop1 As Integer

Property Prop2 As String

End Class



End Class

  1. Helpful
There are no comments made yet.
Mark Lee @Appeon Accepted Answer Pending Moderation
  1. Monday, 13 April 2020 08:26 AM UTC
  2. PowerBuilder
  3. # 1

Hi Arcady,

Ricardo is right.

BTW, we also recommend that you use the .NET DLL Importer tool to import the .NET class to PowerBuilder first, and then call the imported object and function directly to execute the corresponding .NET code.

.NET DLL Importer can import the names and data types of the .NET classes, functions, properties, and parameters from the .NET assembly to the application PBL. It creates the DotNetObject object as an NVO for each .NET class and then imports the .NET functions to the NVO. After that, you can write scripts to call the NVO and functions directly to execute the corresponding .NET code. It can also create the DotNetAssembly object for each DotNetObject object and add try-catch scripts to catch and handle the errors, which can greatly simplify the scripts that you need to write.

https://docs.appeon.com/appeon_online_help/pb2019r2/application_techniques/ch20s02.html

Regards,

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.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.