如何在powerbuilder中使用c#dll调用类的静态方法

时间:2017-09-08 11:06:51

标签: c# dll powerbuilder

我有一个静态的类,它有一个静态的方法。现在我试图从powerbuilder 12.5.2中调用这个方法。当我运行该程序时,它给我错误,即 "在对象w_main的打开事件中,未找到名称在第18行调用外部对象功能测试。"如何从powerbuilder中调用此方法。我不能使用Main方法,因为我必须返回一个对象,据我所知Main方法可以返回void的int。

这是我班级的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;

namespace ConsoleApplication1
{
    [ComVisible(true)]
    [ClassInterface(ClassInterfaceType.AutoDual)]
    [ProgId("ConsoleApplication1.CallWebService")]
    public class CallWebService
    {
        public static ServiceReference1.DataResult callService(string         
        programId, string loginName, string [] arr)
        {
            try
            {
                string [] test = new string [1] ;
                test[0] = "Yes";
                System.IO.File.WriteAllLines("C:\\test.txt", test);
                ServiceReference1.ESSServiceClient reService = new 
                ServiceReference1.ESSServiceClient();
                ServiceReference1.DataPara para = new 
                ServiceReference1.DataPara();
                para.AppAsset = arr;
                ServiceReference1.DataResult ss = new 
                ServiceReference1.DataResult();
                ss = reService.WSRes(programId, loginName, para);
                return ss;
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }
    }
}

这是powerbuilder的代码:

String msg,arr[]
int li_providerType,li_rtn

oleobject lole_docx
dataresult res


TRY
    any var
    lole_docx = create oleobject
    res = create dataresult
    li_rtn =     lole_docx.ConnectToNewObject("ConsoleApplication1.CallWebService")
    IF li_rtn <> 0 then
            MessageBox( "Error", "Error Loading DLL")
            destroy lole_docx
    ELSE
        arr[1] = "A-Z000001,1"
        res = lole_docx.callService("CM-WA-0001","naphas",arr)
        destroy lole_docx
    END IF

CATCH(RuntimeError er)
    MessageBox( "Error", er.getmessage())
END TRY

0 个答案:

没有答案