1. Tharani Santhanam
  2. PowerBuilder
  3. Monday, 20 May 2024 10:28 AM UTC

Hi,

Without using .Net DLL importer ,i have used LoadWithDotNet() function to connect to the DLL from powerbuilder.

but when i try to create the instance to access the method available in the .net Dll,i am getting null object reference DotNetObject(null).

 

Plese find the sample code to access the DLL from powerbuilder

String ls_dll
DotNetAssembly lcs_ass
DotNetObject lco_instance
String ls_classname

 

Ls_dll = "iPharmUserCred.dll"
ls_classname = "MyNamespace.SimpleClass" // Replace with the actual namespace and class name
ls_methodname1 = "SayHello" // Replace with the actual method name

//Instantiates the DotNetAssembly object
lcs_ass = create DotNetAssembly

//Loads the DLL
Ll_return = lcs_ass.LoadWithDotNet(ls_dll)
//Checks the result
If ll_return < 0 then
Messagebox("Load "+ls_dll+" Failed", lcs_ass.ErrorText)
Return ll_return
End if

//Creats the instance
ll_return = lcs_ass.createinstance (ls_classname , lco_instance)--> can't able to create the instance
if ll_return < 0 then
messagebox ("CreateInstance Failed", lcs_ass.errortext)
return
end if

// Invoke the method with arguments
ll_return = lco_instance.Invoke(ls_methodname1, la_result)

// Clean up
destroy lco_instance
destroy lcs_ass

 

 

Please find the simple .net code which has been created in .net 6.0 

 

using System;

namespace MyNamespace
{
public class SimpleClass
{
public string SayHello()
{
return "Hello from .NET!";
}
}
}

DLL created with .net 6.0 can invoked from Powerbuilder uisng LoadwithDotnet () -->is this right?

 

 

 Question 2:

Suppose if i use .Net DLL importer ,then in future if there is any change in DLL ,if i done some minor logical changes in function ,Do i need to import the DLL once again.Or else .Net DLL can be delivered separately with the existing powerbuilder exe.

Thanks,

Tharani S

 

Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Monday, 20 May 2024 15:31 PM UTC
  2. PowerBuilder
  3. # 1

I suggest you use the .NET DLL Importer, it was made to prevent these exact types of issues from occurring when doing things manually.

___

Suppose if i use .Net DLL importer ,then in future if there is any change in DLL ,if i done some minor logical changes in function ,Do i need to import the DLL once again.Or else .Net DLL can be delivered separately with the existing powerbuilder exe.

If you only make logical changes and no interface changes there's no need to run the importer tool again.

 

Regards,
Francisco

Comment
  1. Tharani Santhanam
  2. Tuesday, 21 May 2024 06:48 AM UTC
Thank you for your confirmation
  1. Helpful
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.