Foxtable(狐表)用户栏目专家坐堂 → [求助]第三方DLL引用问题


  共有2728人关注过本帖树形打印复制链接

主题:[求助]第三方DLL引用问题

帅哥哟,离线,有人找我吗?
54292550
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:287 积分:4225 威望:0 精华:0 注册:2011/8/19 10:07:00
[求助]第三方DLL引用问题  发帖心情 Post By:2018/7/29 12:29:00 [只看该作者]

VB.net 引用代码有示例。怎么转换到foxtable里面?

Namespace WinTcpS7
    Public Class PlcClient
        Public Sub New()

        Public Function Bit_Reset(Handle As Integer, Memory As PlcMemory, Block As UShort, Address As UShort, Bit As UShort) As Short
        Public Function Bit_Set(Handle As Integer, Memory As PlcMemory, Block As UShort, Address As UShort, Bit As UShort) As Short
        Public Function Bit_Test(Handle As Integer, Memory As PlcMemory, Block As UShort, Address As UShort, Bit As UShort) As Boolean
        Public Function Bit_Test(Handle As Integer, Memory As PlcMemory, Block As UShort, Address As UShort, Bit As UShort, ByRef State As Boolean) As Short
        Public Function CmdRead(Handle As Integer, Memory As PlcMemory, ValType As DataType, Block As UShort, Address As UShort) As String
        Public Function CmdRead(Handle As Integer, Memory As PlcMemory, ValType As DataType, Block As UShort, Address As UShort, Count As UShort, ByRef Redata() As String) As Short
        Public Function CmdRead(Handle As Integer, Memory As PlcMemory, ValType As DataType, Block As UShort, Address As UShort, Count As UShort, ByRef Redata() As Object) As Short
        Public Function CmdReadString(Handle As Integer, Memory As PlcMemory, Block As UShort, Address As UShort, PlcDataSize As UShort) As String
        Public Function CmdWrite(Handle As Integer, Memory As PlcMemory, ValType As DataType, Block As UShort, Address As UShort, Count As UShort, ByRef Data() As String) As Short
        Public Function CmdWrite(Handle As Integer, Memory As PlcMemory, ValType As DataType, Block As UShort, Address As UShort, Count As UShort, ByRef Data() As Object) As Short
        Public Function CmdWriteString(Handle As Integer, Memory As PlcMemory, Block As UShort, Address As UShort, PlcDataSize As UShort, Data As String) As Short
        Public Function DataConvert(SourType As DataType, SourData As Object, DestType As DataType, ByRef DestData As Object, Optional StartByte As Short = -1) As Short
        Public Function DeLink(Handle As Integer) As Short
        Public Function EntLink(pcIP As String, pcPort As UShort, plcIP As String, plcPort As UShort, Rack As UShort, Slot As UShort, SN As String, ByRef Handle As Integer, Optional WaitTime As UShort = 2000) As Short
        Public Function GetDataBit(Data As Integer, Bit As Short) As Boolean
        Public Function SetDataBit(Data As Integer, Bit As Short, SetVal As Boolean) As Integer

        Public Enum DataType
            INT16 = 1
            UINT16 = 2
            DINT32 = 3
            HEX32 = 4
            REAL32 = 5
            BIN16 = 6
            CHAR8 = 7
            BYTE8 = 8
        End Enum

        Public Enum PlcMemory
            DI = 1
            DQ = 2
            MR = 3
            DR = 4
            AI = 5
            AQ = 6
        End Enum
    End Class
End Namespace



调用连接

        Dim re As Short
        Dim restr As String = ""
        re = PLC.EntLink(Trim(txtLocalIP.Text), CUShort(txtLocalPort.Text), Trim(txtRemoteIP.Text), CUShort(txtRemotePort.Text), 0, 2, "DEMO", Handle1)
[此贴子已经被作者于2018/7/29 12:32:29编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/7/29 16:09:00 [只看该作者]

全局代码

 

Public Class PlcClient
Public Sub New()
End Sub

Public Function Bit_Reset(Handle As Integer, Memory As PlcMemory, Block As UShort, Address As UShort, Bit As UShort) As Short
End Function

Public Function Bit_Set(Handle As Integer, Memory As PlcMemory, Block As UShort, Address As UShort, Bit As UShort) As Short

End Function
Public Function Bit_Test(Handle As Integer, Memory As PlcMemory, Block As UShort, Address As UShort, Bit As UShort) As Boolean
End Function

Public Function Bit_Test(Handle As Integer, Memory As PlcMemory, Block As UShort, Address As UShort, Bit As UShort, ByRef State As Boolean) As Short
End Function

Public Function CmdRead(Handle As Integer, Memory As PlcMemory, ValType As DataType, Block As UShort, Address As UShort) As String
End Function

Public Function CmdRead(Handle As Integer, Memory As PlcMemory, ValType As DataType, Block As UShort, Address As UShort, Count As UShort, ByRef Redata() As String) As Short
End Function

Public Function CmdRead(Handle As Integer, Memory As PlcMemory, ValType As DataType, Block As UShort, Address As UShort, Count As UShort, ByRef Redata() As Object) As Short
End Function

Public Function CmdReadString(Handle As Integer, Memory As PlcMemory, Block As UShort, Address As UShort, PlcDataSize As UShort) As String

End Function
Public Function CmdWrite(Handle As Integer, Memory As PlcMemory, ValType As DataType, Block As UShort, Address As UShort, Count As UShort, ByRef Data() As String) As Short
End Function

Public Function CmdWrite(Handle As Integer, Memory As PlcMemory, ValType As DataType, Block As UShort, Address As UShort, Count As UShort, ByRef Data() As Object) As Short
End Function

Public Function CmdWriteString(Handle As Integer, Memory As PlcMemory, Block As UShort, Address As UShort, PlcDataSize As UShort, Data As String) As Short

End Function
Public Function DataConvert(SourType As DataType, SourData As Object, DestType As DataType, ByRef DestData As Object, Optional StartByte As Short = -1) As Short

End Function
Public Function DeLink(Handle As Integer) As Short

End Function
Public Function EntLink(pcIP As String, pcPort As UShort, plcIP As String, plcPort As UShort, Rack As UShort, Slot As UShort, SN As String, ByRef Handle As Integer, Optional WaitTime As UShort = 2000) As Short

End Function
Public Function GetDataBit(Data As Integer, Bit As Short) As Boolean

End Function
Public Function SetDataBit(Data As Integer, Bit As Short, SetVal As Boolean) As Integer
End Function

 

Public Enum DataType
INT16 = 1
UINT16 = 2
DINT32 = 3
HEX32 = 4
REAL32 = 5
BIN16 = 6
CHAR8 = 7
BYTE8 = 8
End Enum


Public Enum PlcMemory
DI = 1
DQ = 2
MR = 3
DR = 4
AI = 5
AQ = 6
End Enum
End Class


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/7/29 16:10:00 [只看该作者]

 

具体vb.net实例发上来测试。

 


 回到顶部
帅哥哟,离线,有人找我吗?
54292550
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:287 积分:4225 威望:0 精华:0 注册:2011/8/19 10:07:00
  发帖心情 Post By:2018/7/29 16:43:00 [只看该作者]

甜老师,,这个是不是一个托管的DLL?
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:client vb2010.rar


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/7/29 17:37:00 [只看该作者]

1、你WinTcpS7.dll的版本不对,请去找一个 .net 2.0 或者 .net 3.5 的版本。

 

2、在foxtable直接引用dll,然后照抄调用的代码即可


 回到顶部
帅哥哟,离线,有人找我吗?
54292550
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:287 积分:4225 威望:0 精华:0 注册:2011/8/19 10:07:00
  发帖心情 Post By:2018/7/29 17:38:00 [只看该作者]

直接引用dll。。。。
报错:
.NET Framework 版本:2.0.50727.8825
Foxtable 版本:2018.3.9.1
错误所在事件:窗口,窗口1,Button1,Click
详细错误信息:
未能加载文件或程序集“WinTcpS7, Version=3.4.0.2, Culture=neutral, PublicKeyToken=null”或它的某一个依赖项。生成此程序集的运行时比当前加载的运行时新,无法加载此程序集。

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


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/7/29 17:43:00 [只看该作者]

1、你WinTcpS7.dll的版本不对,请去找一个 .net 2.0 或者 .net 3.5 的版本。

 

2、在foxtable直接引用dll,然后照抄调用的代码即可


 回到顶部
帅哥哟,离线,有人找我吗?
54292550
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:287 积分:4225 威望:0 精华:0 注册:2011/8/19 10:07:00
  发帖心情 Post By:2018/7/29 18:07:00 [只看该作者]

甜老师,这个是从网上下载的。没看到有别的版本,有其它办法吗?

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/7/29 18:20:00 [只看该作者]

以下是引用54292550在2018/7/29 18:07:00的发言:
甜老师,这个是从网上下载的。没看到有别的版本,有其它办法吗?

 

1、如果你有源码,请打开dll的源码,重新编译;

 

2、不然,你抄厂家给你一个对应版本的dll使用。


 回到顶部