[英]System.EntryPointNotFoundException: Unable to find an entry point
I have convert VB6 to c# while executing it generate this error 我在执行它时将VB6转换为c#会产生此错误
FROM VB6 从VB6
Declare Function OpenCommPort Lib "C:\Program Files\MR705API.dll" Alias "?OpenCommPort@@YGHPADPAPAX@Z" (ByVal PortName As String, ByRef hCom As Long) As Long
Declare Function CloseCommPort Lib "C:\Program Files\MR705API.dll" Alias "?CloseCommPort@@YGHPAX@Z" (ByVal hCom As Long) As Long
Declare Function SetLED Lib "C:\Program Files\MR705API.dll" Alias "?SetLED@@YGHPAXEE@Z" (ByVal hCom As Long, ByVal Led As Byte, ByVal Addr As Byte) As Long
Declare Function ActiveBuzzer Lib "C:\Program Files\MR705API.dll" Alias "?ActiveBuzzer@@YGHPAXEE@Z" (ByVal hCom As Long, ByVal DelayTime As Byte, ByVal Addr As Byte) As Long
Declare Function Iso14443Reqa Lib "C:\Program Files\MR705API.dll" Alias "?Iso14443Reqa@@YGHPAXEPAEE@Z" (ByVal hCom As Long, ByVal ReqAMode As Byte, ByVal ATQ As String, ByVal Addr As Byte) As Long
Declare Function Iso14443Anticoll Lib "C:\Program Files\MR705API.dll" Alias "?Iso14443Anticoll@@YGHPAXEPAE1E@Z" (ByVal hCom As Long, ByVal AnticollMode As Byte, ByVal Uid As String, ByVal MultiTag As String, ByVal Addr As Byte) As Long
IN C# 在C#中
[DllImport ("MR705API.dll")]
public static extern long OpenCommPort(String portName, ref long hCom );
[DllImport ("MR705API.dll")]
public static extern long CloseCommPort(long hCom);
[DllImport ("MR705API.dll")]
public static extern long SetLED(long hCom, byte Led , byte Addr);
[DllImport ("MR705API.dll")]
public static extern long ActiveBuzzer (long hcom, byte DelayTime, byte Addr);
[DllImport ("MR705API.dll")]
public static extern long Iso14443Reqa (long hcom, byte ReqAMode, string ATQ, byte Addr);
And how I use it.. 以及我如何使用它。
public void doReader() {
Result = OpenCommPort("COM9", ref HANDLE);
....
....
}
Exception 例外
System.EntryPointNotFoundException: Unable to find an entry point named 'OpenCommPort' in DLL 'MR705API.dll'.
at TrueReader.MainForm.OpenCommPort(String portName, Int64& hCom)
at TrueReader.MainForm.doReader() in c:\Users\sattha\Documents\SharpDevelop Projects\TrueReader\TrueReader\MainForm.cs:line 59
at TrueReader.MainForm.Timer1Tick(Object sender, EventArgs e) in c:\Users\sattha\Documents\SharpDevelop Projects\TrueReader\TrueReader\MainForm.cs:line 54
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at TrueReader.Program.Main(String[] args) in c:\Users\sattha\Documents\SharpDevelop Projects\TrueReader\TrueReader\Program.cs:line 27
Can any one guide me, what did I do wrong?? 谁能指导我,我做错了什么? or what did I miss.
还是我想念什么。
I don't know how this .dll wrote and in which languages. 我不知道此.dll是如何编写的以及使用哪种语言。
but it had used in VB6 before. 但它曾经在VB6中使用过。
YOU SHOULD DEFINE ENTRY POINT FOR EACH DLLIMPORT FUNCTIONS
您应该为每个DLL导入功能定义入口点
Just copy entry point from Alias
from your VB6 code to C# 只需将
Alias
入口点从您的VB6代码复制到C#
FOR EXAMPLE... "OpenCommPort" in VB6 例如... VB6中的“ OpenCommPort”
Alias "?OpenCommPort@@YGHPADPAPAX@Z"
别名“?OpenCommPort @@ YGHPADPAPAX @ Z”
TO -> "OpenCommPort" in C# TO-> C#中的“ OpenCommPort”
[DllImport ("MR705API.dll",
EntryPoint="?OpenCommPort@@YGHPADPAPAX@Z")]
public static extern int OpenCommPort(string portName, ref int hCom);
ADDINTIONAL ADDINTIONAL
long
in VB6 equivalent to int
in C# VB6中的
long
等效于C#中的 int
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.