1. Tharani Santhanam
  2. PowerBuilder
  3. Friday, 17 May 2024 07:41 AM UTC

Hi,

Am using PB 2022 R3, planning to consume .NET dll using OLE Object in PB,
.NET dll is created  and build using .net 6 core (VS 2022) - Is it possible to consume it in PB?,

while consuming i am getting dll cannot be created.

Note: I have already consumed .NET dll in PB successfully (which was created using Target Framework 4.5 (VS2019)).

Thanks,
Tharani

Tharani Santhanam Accepted Answer Pending Moderation
  1. Monday, 20 May 2024 09:48 AM UTC
  2. PowerBuilder
  3. # 1

Yes i declared the instance,please find the below code for your reference

Long ll_return
String ls_dll
DotNetAssembly lcs_ass
DotNetObject lco_instance

lcs_ass = create DotNetAssembly

//Loads the DLL
Ll_return = lcs_ass.LoadWithDotNetCore(ls_dll)

 

ll_return  = lcs_ass.CreateInstance(ls_classname, lco_instance)

 

 

my c# code is 

 

using System;

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

 

Comment
There are no comments made yet.
Tharani Santhanam Accepted Answer Pending Moderation
  1. Monday, 20 May 2024 08:31 AM UTC
  2. PowerBuilder
  3. # 2

Hi All,

Instead of using DLL importer ,i tried with loadwithdotnet() function,I was able to succesfully load the .net6.0 dll,but when i try to invoke the method avilable in the dll using instance creation with classname of the dll,i am getting error ,instance cannot be created,it returns null

lcs_ass = CREATE DotNetAssembly

// Load the DLL
ll_return = lcs_ass.LoadWithDotNet(ls_dll)

// Check if the DLL was loaded successfully
IF ll_return < 0 THEN
MessageBox("Load DLL Failed", lcs_ass.ErrorText)
RETURN
END IF

// Create an instance of the .NET class
ll_return = lcs_ass.CreateInstance(ls_classname, lco_instance) --> getting error in this code

 

can anyone help me on this.

 

Thanks,

Tharani S

Comment
  1. Andreas Mykonios
  2. Monday, 20 May 2024 09:30 AM UTC
Hi.

How have you declared lco_instance? In general we do have to little information about the class you are trying to use. It's difficult to help.

Andreas.
  1. Helpful
There are no comments made yet.
Bruce Armstrong Accepted Answer Pending Moderation
  1. Friday, 17 May 2024 18:32 PM UTC
  2. PowerBuilder
  3. # 3

Have to jump on the bandwagon here.  Don't do it!  That is, don't use OLE to consume the .Net DLL.  There are just too many limitations.  It was a  workaround until PowerBuilder was able to consume .Net directly.  But that time has come now.  Use the .Net Importer.

The "getting dll cannot be created" error doesn't make any sense to me as well.  Not sure why you would get that error access in DLL through OLE.

Comment
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Friday, 17 May 2024 14:43 PM UTC
  2. PowerBuilder
  3. # 4

Yes, PB 2022 R3 supports .NET 6.  But I don't get why you aren't using the .NET DLL importer to directly consume it in PB?  https://docs.appeon.com/pb2022r3/application_techniques/Calling_C_Assembly_in_an_Application.html

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 17 May 2024 13:56 PM UTC
  2. PowerBuilder
  3. # 5

Hi Tharani ;

   Yes, .NET DLLs can now be consumed directly in Appeon PB 2019 Rx & higher using the new .NET DLL Importer tool ...

https://docs.appeon.com/pb2022r3/application_techniques/Importing_CSharp_assembly.html

HTH

Regards ... Chris

 

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.