vb.net pRO 2017 无法使用具有名为 'WriteOnly' 的函数的 DLL 构建,该函数是 VB 保留字
vb.net pRO 2017 cannot build with a DLL that has function named 'WriteOnly' which is VB reserved word
我该如何解决这个问题?
我需要连接到一个 DLL(来自 Inheco.com 的 InhecoMTCdll.DLL),该 DLL 在其 API 中公开函数名称 'WriteOnly()',这是一个 VB.NET 保留字。
那么问题是当我声明 API.
时,我的 VB.NET windows 表单应用程序出现构建错误
有没有办法解决这个问题?我没有 DLL 的源代码。我尝试用 JetBrains dotPeek 反编译,但看不到如何重新编译。
API 共 InhecoMTCdll.DLL .....................
public int FindTheUniversalControl(
int ID);
public void WriteOnly(string msg);
public string ReadSync();
我在 VB.NET Pro 2017 windows 应用程序中声明 API....
Imports System.Runtime.InteropServices
Module Inheco_Thermoshake_interface
Public Class NativeMethods
' Function within DLL:
' Public int FindTheUniversalControl(int ID);
' which corresponds to VB.NET declaration:
<DllImport("InhecoMTCdll.dll")>
Public Shared Function FindTheUniversalControl(ByRef ID As Int32) As Int32
End Function
' Need to re-program DLL with Inheco_WriteOnly because WriteOnly is VB keyword.
' public void WriteOnly(string msg);
<DllImport("InhecoMTCdll.dll")>
Public Shared Sub WriteOnly(ByRef msg As Byte()) <<<<<<< BUILD ERROR: "KEYWORD IS NO VALID AS AN IDENTIFIER"
End Sub
' public string ReadSync();
<DllImport("InhecoMTCdll.dll")>
Public Shared Function ReadSync() As Byte()
End Function
End Class
End Module
您可以使用 VB.Net 中的保留字作为函数名和变量名,但要用方括号将其括起来。例如:
Public Shared Sub [WriteOnly](ByRef msg As Byte())
我该如何解决这个问题?
我需要连接到一个 DLL(来自 Inheco.com 的 InhecoMTCdll.DLL),该 DLL 在其 API 中公开函数名称 'WriteOnly()',这是一个 VB.NET 保留字。
那么问题是当我声明 API.
有没有办法解决这个问题?我没有 DLL 的源代码。我尝试用 JetBrains dotPeek 反编译,但看不到如何重新编译。
API 共 InhecoMTCdll.DLL .....................
public int FindTheUniversalControl(
int ID);
public void WriteOnly(string msg);
public string ReadSync();
我在 VB.NET Pro 2017 windows 应用程序中声明 API....
Imports System.Runtime.InteropServices
Module Inheco_Thermoshake_interface
Public Class NativeMethods
' Function within DLL:
' Public int FindTheUniversalControl(int ID);
' which corresponds to VB.NET declaration:
<DllImport("InhecoMTCdll.dll")>
Public Shared Function FindTheUniversalControl(ByRef ID As Int32) As Int32
End Function
' Need to re-program DLL with Inheco_WriteOnly because WriteOnly is VB keyword.
' public void WriteOnly(string msg);
<DllImport("InhecoMTCdll.dll")>
Public Shared Sub WriteOnly(ByRef msg As Byte()) <<<<<<< BUILD ERROR: "KEYWORD IS NO VALID AS AN IDENTIFIER"
End Sub
' public string ReadSync();
<DllImport("InhecoMTCdll.dll")>
Public Shared Function ReadSync() As Byte()
End Function
End Class
End Module
您可以使用 VB.Net 中的保留字作为函数名和变量名,但要用方括号将其括起来。例如:
Public Shared Sub [WriteOnly](ByRef msg As Byte())