Use C# created DLL in PowerBuilder 12.5.2

♀尐吖头ヾ 提交于 2021-01-29 01:32:12

问题


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.


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/34306591/use-c-sharp-created-dll-in-powerbuilder-12-5-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!