1. David Peace (Powersoft "The PowerBuilder & C# People")
  2. PowerBuilder
  3. Wednesday, 17 June 2020 09:55 AM UTC

Hi Guys

I'm creating a simple wrapper for a .Net DLL in order to remove the complex return values. Using SnapDevelop I have created a simple C# Class Object that references the extrernal DLL. My C# Code is:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Integral.Library.GuardianClient;


namespace PBSagePay
{
    public class PBSagePay
    {
        public Boolean ProcTrans(String TransactionType, Decimal Amount, ref String ResultText, ref Int32 ResponseCode)
        {
            TillInformation TillInfo = new TillInformation();
            TransactionInfo TransInfo = new TransactionInfo();
            TransactionHook TransHook = new TransactionHook();
            TransactionHook.TRANSACTIONHOOK_TRANSACTIONTYPE TransType = new TransactionHook.TRANSACTIONHOOK_TRANSACTIONTYPE();

            //Setup Till Info
            TillInfo.MerchantName = "Test Hotel";
            TillInfo.Address1 = "Test Addr1";

            // Setup the transaction type - Default Sale
            
            TransType = TransactionHook.TRANSACTIONHOOK_TRANSACTIONTYPE.INT_TT_SALE;
            if (TransactionType.ToUpper() == "REFUND")
            {
                TransType = TransactionHook.TRANSACTIONHOOK_TRANSACTIONTYPE.INT_TT_REFUND;
            }
            if (TransactionType.ToUpper() == "PREAUTH")
            {
                TransType = TransactionHook.TRANSACTIONHOOK_TRANSACTIONTYPE.INT_TT_PREAUTH;
            }

            // Prepare The Amount
            Int32 PenceAmount = (Int32) Decimal.Floor(Amount * 100);
            
            if (TransHook.Process(TransType, 25000, ref TillInfo, ref TransInfo))
            {
                ResponseCode = (Int32)TransInfo.ResponseCode;
                ResultText = "All OK";                
                return true;
            }
            ResultText = "Failed";
            ResponseCode = (Int32)TransInfo.ResponseCode;
            return false;

        }
    }
}

I placed my resulting DLL along with the DLLs from the 3rd party application.

When I try and Load in the DLL created I get the following Could not load file or assembly.... The system cannot find the file specified. Nothing appears in the Select & Preview list.

I do not seem to have my ducks in order, any suggestions?

Cheers

David

Accepted Answer
  1. Wednesday, 17 June 2020 11:21 AM UTC
  2. PowerBuilder
  3. # Permalink

Ah I've got it, the built DLL was Dot Net Core, I was not expecting that by default. I could not find an options in the Project Properties to change the build type?

Anyway my problem is solved for now :)

Cheers

Comment
  1. Armeen Mazda @Appeon
  2. Wednesday, 17 June 2020 14:37 PM UTC
Thanks for sharing the solution!
  1. Helpful
  1. David Peace (Powersoft "The PowerBuilder & C# People")
  2. Wednesday, 17 June 2020 15:14 PM UTC
You're Welcome.



I'm still learning how this tool "really" works and what it can do for us. When you can support more complex datatypes it will be brilliant. Accessing them in PB Script is a dream :)



Thanks

David
  1. Helpful
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Friday, 19 June 2020 10:59 AM UTC
  2. PowerBuilder
  3. # 1

Ah I've got it, the built DLL was Dot Net Core, I was not expecting that by default. I could not find an options in the Project Properties to change the build type?

Anyway my problem is solved for now :)

Cheers

Hi David.

You mention that the issue was that the dll was built using .net core. I wonder why this was an Issue? I believe .net core assemblies are also supported by .NET Dll Importer tool. Maybe you were missing the appropriate runtime?

Andreas.

Comment
  1. David Peace (Powersoft "The PowerBuilder & C# People")
  2. Friday, 19 June 2020 14:13 PM UTC
On the DLL loader tool you have a choice or Core or not. I chose not core and it errored. I assumed that the dll built would be Dot Net rather than core. In VS the dll would notmally ne Dot Net rather tthan core by default. Probably becuase I use an old version of VS :)



Either way it was really a me problem ;-)
  1. Helpful
  1. Armeen Mazda @Appeon
  2. Friday, 19 June 2020 15:09 PM UTC
Microsoft is replacing .NET with .NET Core. Microsoft is supposed to do this in the next version. https://devblogs.microsoft.com/dotnet/introducing-net-5/
  1. Helpful
  1. David Peace (Powersoft "The PowerBuilder & C# People")
  2. Monday, 22 June 2020 10:53 AM UTC
Thanks Armeen, useful information.
  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.