以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]dll程序编写  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=143519)

--  作者:ajie5211
--  发布时间:2019/11/27 15:49:00
--  [求助]dll程序编写

VS2019中写程序关编译成dll

代码如下

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using XMLDaClientdll.XMLWrapper;

namespace XMLDaClientdll
{
    public interface IXMLDaClientdll
    {
        string Connect(string txtUrl);
    }
    public class ConnectClass:IXMLDaClientdll
    {
        public string Connect(string txtUrl)
        {
            XMLWrapper.OPC_XML_DA_WrapperService service = new XMLWrapper.OPC_XML_DA_WrapperService();
            service.Url = "http://" + txtUrl + "/soap";

            ReplyBase reply;
            ServerStatus Status;
            try
            {
                reply = service.GetStatus("en-US", "", out Status);
                return Status.StatusInfo.ToString();
            }
            catch (Exception excp)
            {
                return excp.Message;

            }
            finally
            {
            }
        }
    }
}

 

狐表中引用此dll,全局代码中写

Public Declare Function connectxml Lib "XMLDaClientdll.dll" Alias "Connect" (ByVal txtUrl As String) As String  

测试Output.Show(connectxml("192.168.1.222"))

报错


图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看

不知道要修改哪里?偶是小白,C#看了一周多,还是云里雾里的。


--  作者:有点蓝
--  发布时间:2019/11/27 15:52:00
--  
去掉全局代码,直接添加引用即可:http://www.foxtable.com/webhelp/topics/1936.htm

调用

Output.Show(XMLDaClientdll.Connect(192.168.1.1))

--  作者:ajie5211
--  发布时间:2019/11/27 16:00:00
--  

提示错误

---------------------------
错误
---------------------------
编译错误:“Connect”不是“XMLDaClientdll”的成员。

 

错误代码:Output.Show(XMLDaClientdll.Connect("192.168.1.222"))
---------------------------
确定  
---------------------------


--  作者:有点蓝
--  发布时间:2019/11/27 16:08:00
--  
Output.Show(new XMLDaClientdll.ConnectClass().Connect(192.168.1.1))
--  作者:ajie5211
--  发布时间:2019/11/27 16:10:00
--  
以下是引用有点蓝在2019/11/27 16:08:00的发言:
Output.Show(new XMLDaClientdll.ConnectClass().Connect(192.168.1.1))

可以了,谢谢!