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! :)
2021-11-09 7:13:48 PM
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.
I'll keep it in mind.