1. ATK Gimmy Susan
  2. PowerBuilder
  3. Wednesday, 23 September 2020 15:17 PM UTC

Good morning Guru.


I am using '.NET DLL Importer' and notice a strange thing.

When Powerbuilder object is generated among the instance variables exists 'is_assemblypath' (see image )

I note that it contains the absolute references of the source directory.

What exactly is it for?

In our case the development folder is not the same of the installation folder of the customer program.

I did two tests:
1) Leave the reference as generated. The system sometimes goes into error saying that it cannot load the assembly.
2) Deleted the absolute reference and left only the name of the dll. It seems to be improving, but again it fails. More rarely. (see image)

 

How is the problem solved?

 

Thanks in advance for the answers

 

 

Accepted Answer
ATK Gimmy Susan Accepted Answer Pending Moderation
  1. Thursday, 24 September 2020 13:22 PM UTC
  2. PowerBuilder
  3. # Permalink

Thanks Brad for your suggestion.

 

I solved it like this:

In the user object constructor I added:

*******************************

integer i
string ls_dll

IF Handle(GetApplication()) <> 0 THEN

   for i = len(is_assemblypath) to 1 step -1
      if mid(is_assemblypath, i, 1) = '\' Then
         ls_dll = right(is_assemblypath, len(is_assemblypath) - i)
         exit
      end if
   next
   is_assemblypath = go_prg.am.get_exepath() + '\' + ls_dll 

end if

************************************************

// go_prg.am.get_exepath()

[global declaration]

FUNCTION int GetModuleFileNameW(ulong hinstModule, REF string lpszPath, ulong cchPath) LIBRARY "kernel32" 

 

[code]
integer i
string ls_Path
string ls_dir
unsignedlong lul_handle

ls_Path = space(1024)

lul_handle = Handle(GetApplication())
GetModuleFilenameW(lul_handle, ls_Path, 1024)

 for i = len(ls_path) to 1 step -1
   if mid(ls_path, i, 1) = '\' Then
      ls_dir = left(ls_path, i - 1 )
      exit
   end if
next

return ls_dir

************************************************

 

 

I still think it's something that Appeon needs to fix.

It doesn't seem right that at each regeneration I have to modify the object manually.

Gimmy

 

 

Comment
  1. Brad Wery
  2. Friday, 25 September 2020 13:27 PM UTC
You should submit an enhancement request. All they would need to do is provide a second option, right click on the user object and all developers to select Update References. Then all it does is update the function references and not create a new object.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Saturday, 26 September 2020 11:02 AM UTC
  2. PowerBuilder
  3. # 1

I do think a valid point is being made here:

Appeon could incorporate some options in the DLL importer tool:

1) give us the option to generate an ancestor class or not

2) that ancestor class would hold all the basic instance variables, basic functions and events.

3) the imported user functions would go to an object inherited from this ancestor class, as also would the assembly name assigned somewhere in the child object.

4) the ancestor class would then call a function to get the ancestor class name from the child object

This would give us the possibility to write generic functionality in the ancestor class.

When re-importing a library, we would use our already existing and adopted version of the ancestor class and delete the newly generated ancestor class. (it would be nice if the tool would ask us to overwrite the already existing ancestor in case we are importing things in to the same library where the modified ancestor was saved before).

Or even better, give as 2 checkboxes:

- use an ancestor class (yes or no)

- generate the ancestor class (yes or no): this would "use" an ancestor class, but not necessarily generate a new one, since we indicate with this checkbox that we already have one. 

 

I'll make a feature request of this, pointing to this Q&A

regards.

Comment
  1. Miguel Leeuwe
  2. Saturday, 26 September 2020 11:07 AM UTC
  1. Helpful
  1. Armeen Mazda @Appeon
  2. Saturday, 26 September 2020 14:37 PM UTC
Thanks
  1. Helpful
There are no comments made yet.
Brad Wery Accepted Answer Pending Moderation
  1. Wednesday, 23 September 2020 16:20 PM UTC
  2. PowerBuilder
  3. # 2

What I did was removed the absolute path from the variable you mentioned. I then modified the method that loads the assembly (I forget the name of the auto generated method but it has Load in the name and I think it's the only method that references the assemblypath variable).

I store the install location of the assembly in the registry so that's where I get the path information:

gnv_app.of_GetInstallDirectory() + is_assemblypath

If I ever have to regenerate the nvo, I have to make these changes again.

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.