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