1. Guillem Muñoz
  2. PowerBuilder
  3. Tuesday, 9 November 2021 18:17 PM UTC

Hi,
I am trying to use the feature that include PowerBuilder to Import .NET DLLs.
So I have created a very basic app with PowerBuilder that include a non visual object imported with the Tool .NET DLL Importer.
This non visual object is a C# .NET DLL made with Visual Studio 2019.

The DLL is very simple, it contains a function that return a string. 'ok'

public string Text()
{
string ret="OK";
return ret;
}

I had guided in this video to do all the steps until I deployed the app.

 

When I deploy the Target it works on my computer because I have all .Net and Framework .NET and Core... due to installation of visual studio 2019.

The big problem for me is when I have to deploy on the other machines.
I know that I have to install .NET (at this time 6.0) and put the DLL in the same directory. Maybe I am missing something in this point.

The app opens, but when I call the dll do not nothing.
I have put a simple comand button in the window. On clicked event call the non visual object function (DLL). But it did not nothing. It is suposed to return OK as a messagebox.

I made the same thing with C++ dll and imported as a extension (Import PB Extension...) and it worked.

On the client computer I have all the dll's of PowerBuilder plus the .NET DLL and C++ DLL.

I read about the PDFUtils post that Bruce Armstong made: https://community.appeon.com/index.php/codeexchange/powerbuilder/286-pdfutils
and more or less is the same way I want to do but with my code. So I downloaded the files, I put on other machine that has .Net Core installed and it worked.

I am sure that I am missing something but I don't know what is it...

Thanks! :) smile

2021-11-09 7:13:48 PM

 

 

References
  1. https://community.appeon.com/index.php/codeexchange/powerbuilder/286-pdfutils
  2. https://www.youtube.com/watch?v=tghi16U4CcU
Accepted Answer
Guillem Muñoz Accepted Answer Pending Moderation
  1. Wednesday, 10 November 2021 15:44 PM UTC
  2. PowerBuilder
  3. # Permalink

Hello Miguel, thanks for the answer. 

I did what you wrote but it did not work for me when I deployed the app.

I have found a solution but I do not know if it is the best way to do that. Let me explain, on PowerBuilder I did click on Edit Source on the nvo (DLL .NET) and I have found this: 

forward
global type nvo_connectividadnet from dotnetobject
end type
end forward

global type nvo_connectividadnet from dotnetobject
event ue_error ( )
end type
global nvo_connectividadnet nvo_connectividadnet

type variables

PUBLIC:
String is_assemblypath = "N:\Appeon\dll\ping\PowerBuilderNet.dll"
String is_classname = "PowerBuilderNet.ConnectividadNet"

/* Exception handling -- Indicates how proxy handles .NET exceptions */
Boolean ib_CrashOnException = False

and continue. the code...

The Public string is_assemblypath is where initially is located the DLL when I deploy the app.  So in my computer it works when I run the .exe.

But on the other computers not. But if I change the path of is_assemblypath into this:

String is_assemblypath = "C:\PowerBuilderNet.dll"

Then when I deploy and run the app on another computer it works. Of Course, I have to put the dll on C:\ in my computer and on the other.

Regards.

 

 

Comment
  1. Miguel Leeuwe
  2. Wednesday, 17 November 2021 14:45 PM UTC
Glad you solved it.

You don't have to "edit the source code" to see your is_assemblyPath instance variable: You can see it when you do a normal edit of the object too.

What I do, to avoid the problem of the fixed path is use a "relative" path. You should always try to avoid fixed paths in your applications.

For example, I have a MYDLL.dll file and my application's exe will be running in D:\myapp. I copy the DLL I've created to the d:\myapp\DLLS folder.

My instance variable, instead of having a value of

"D:\myapp\DLLS\MYDLL.dll",

has

".\DLLS\MYDLL.dll"



The only thing you have to be careful with, is that when a user saves/opens files or changes folders in any way at any time when using the application, your relative path won't work anymore. For example after opening a file in c:\mydocuments. The "internal" current directory won't be the folder of your application's EXE anymore. Therefore, before using / creating the nvo of your DLL in the code, you have to make sure that your pointing to directory where your EXE is, so the relative path will work. You can use ChangeDirectory(....) for doing so.

You would have to save the path to your EXE folder somehow right after opening the application (maybe in a global variable or global object).

regards.

  1. Helpful 1
  1. Guillem Muñoz
  2. Wednesday, 17 November 2021 15:24 PM UTC
Thank you very much for the answer.

I'll keep it in mind.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Tuesday, 9 November 2021 18:20 PM UTC
  2. PowerBuilder
  3. # 1

I think that there's a way of creating the DLL in Vstudio in such a way that the .Net Core DLL's are automatically included and distributed.

I'll get back to you if I remember how to do that (it's been a while).

Comment
  1. Guillem Muñoz
  2. Tuesday, 9 November 2021 18:25 PM UTC
Thank you very much for the quick response.
  1. Helpful
  1. Miguel Leeuwe
  2. Tuesday, 9 November 2021 20:39 PM UTC
How to Get a standalone version of .Net CORE to distribute with assembly:

- open a cmd terminal

- Go to the folder where your .sln file is

- dotnet.exe publish -r win-x86



This would generate all necessary .net core dll files

regards
  1. Helpful 2
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.