1

I have created a simple C# class library targetting .Net Framework 4.5.2 with one class using Visual Studio 2015 enterprise edition.

Sample code:

namespace PwdEncryptor
{
    public class Class1
    {
        public string Encrypt (string actualPassword)
        {
           return String.Concat(actualPassword, "Encrypt");
        }
    }
}

I want to use this from my powerbuilder code on another system.

Purpose of doing this is to have common code for encryption of password.

Problem:

I used it in my powerbuilder code by declaring in the Global instance variables like this:

Function string Encrypt(string actualPassword) Library "PwdEncryptor.dll"

And in Open event of the application I wrote:

string pwd
pwd = Encrypt("XYZ")

When I ran the code, I got a message saying "Unknown function name"

To overcome this I tried the solution mentioned here. A small deviation that I took was instead of doing the execution in powerbuilder on the same system I exported the registry which was created & imported to other system where powerbuilder code exists. In this case the error that I got was Bad runtime function refernce at line in Open event of Application object.

Is there a way that I can possibly use the DLL I have created? Am I missing something? Please advise.

Ankit
  • 672
  • 6
  • 18
  • Is the DLL registered on the system which you run your PowerBuilder code? – Matt Balent Dec 16 '15 at 14:02
  • @MattBalent: Yes, it is registered in the Registry. It gets registered as a part of the build on my system from the sample solution present in the link I mentioned in the question. FYI, it gets registered under HKEY_CLASSES_ROOT. I import this registry & then export it on the system having PowerBuilder code. – Ankit Dec 17 '15 at 03:04

2 Answers2

0

You have to expose DLL as COM visible. Detailed info at this answer and this other.

Project properties > Application > Make assembly COM-visible

Community
  • 1
  • 1
Merrin
  • 514
  • 7
  • 20
  • Thanks for your response. I have already made the dll COM visible as suggested in the link I have provided in the question. Maybe you could have a look at the link & then advise if I'm doing anything wrong. – Ankit Dec 21 '15 at 08:24
0

I have resolved this.

Instead of exporting the registry from my system & importing it on the system containing powerbuilder code, I should have registered my C# dll using RegAsm.exe

Once the DLL is registered, the PowerBuilder code is able to use the C# code.

Ankit
  • 672
  • 6
  • 18