PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Calling an unmanaged DLL from Visual Studio 2003 Visual Basic
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Calling an unmanaged DLL from Visual Studio 2003 Visual Basic
![]() |
Calling an unmanaged DLL from Visual Studio 2003 Visual Basic |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hall
I want to call an unmanaged dll, written in eMbedded Visual C++ 4. from Visual Studio 2003 Visual Basic, for an application for Pocket PC 2003 I have tried with "Public Declare Function MSR3000_Open Lib "msr8800.dll" (..." and with the DllImport-statement but the "MissingMethodException" occurs every time I dont know how to set/declare the parameters The function-declaration in the dll typedef DWORD RET_STATUS MSR8800_API RET_STATUS Msr3000_Open(TCHAR *ptrSerialPort, TCHAR *ptrDllVersion TCHAR *ptrFirmwareVersion, void *pPortHandle I have a program written in eMbedded Visual C++ 4.0 and the call from that program looks like this DWORD rs TCHAR szPort[] = _T("COM1:"); // Serial Por TCHAR szDll[40]; // to receive version inf TCHAR szFirm[40]; // to receive firmware versio TCHAR szDummy[20]; // for unused parameter rs = Msr3000_Open(szPort,szDll, szFirm, szDummy) Regards Ã…ke |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Hi Ã…ke
Working with unmanaged dll calls is sometimes quite tricky. There are a few simple steps that you should verify 1. Does the executable locate the correct dl 2. Check the exported symbols with dumpbin /export I'm not completely shure but I think that missing method exceptions only occur when the runtime fails to locate a managed method, and that the exception that you probably should encounter if there is a missmatch between managed/unmanaged code is EntrypointNotFoundException (but I can't verify this at this point Best Regards, Daniel Peterson |
|
|
|
#3 |
|
Guest
Posts: n/a
|
The dumpbin /exports give me 10 9 0000100F ?Msr3000_Open@@YAKPAG00PAX@ It dont say me a thing The following call give me "A managed InvalidCastException" <DllImport("msr8800.dll", CallingConvention:=CallingConvention.Winapi, CharSet:=CharSet.Unicode, EntryPoint:="Msr3000_Open")> Public Shared Function Msr3000_OpenW(ByVal ptrSerialPort As Byte, ByVal ptrDllVersion As Byte, ByVal ptrFirmwareVersion As Byte, ByVal pPortHandle As Byte) As UInt3 End Functio Public svar_open As UInt3 Public svar_close As Int3 Public szPort As Strin Public szDll As Strin Public szFirm As Strin Public szDummy As Strin Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Clic szPort = "COM1: svar = Form1.Msr3000_OpenW(szPort, szDll, szFirm, szDummy svar_open = Form1.Msr3000_OpenW(szPort, szDll, szFirm, szDummy Another question: How do you write the right path on Pocket PC 2003 for msr8800.dll |
|
|
|
#4 |
|
Guest
Posts: n/a
|
http://msdn.microsoft.com/mobility/...f/FAQ/default.a
spx#6.1 -- -- Alex Yakhnin .NET CF MVP www.intelliprog.com | www.opennetcf.org "AkeK" <anonymous@discussions.microsoft.com> wrote in message news:E9BE8C4A-21BC-4A31-8EC1-D7E3DFF78187@microsoft.com... > > The dumpbin /exports give me: > 10 9 0000100F ?Msr3000_Open@@YAKPAG00PAX@Z > > It dont say me a thing! > > The following call give me "A managed InvalidCastException": > > <DllImport("msr8800.dll", CallingConvention:=CallingConvention.Winapi, _ > CharSet:=CharSet.Unicode, EntryPoint:="Msr3000_Open")> _ > Public Shared Function _ > Msr3000_OpenW(ByVal ptrSerialPort As Byte, ByVal ptrDllVersion As Byte, _ > ByVal ptrFirmwareVersion As Byte, ByVal pPortHandle As Byte) As UInt32 > End Function > > Public svar_open As UInt32 > Public svar_close As Int32 > Public szPort As String > Public szDll As String > Public szFirm As String > Public szDummy As String > > Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click > szPort = "COM1:" > svar = Form1.Msr3000_OpenW(szPort, szDll, szFirm, szDummy) > svar_open = Form1.Msr3000_OpenW(szPort, szDll, szFirm, szDummy) > > Another question: How do you write the right path on Pocket PC 2003 for msr8800.dll ? > |
|
|
|
#5 |
|
Guest
Posts: n/a
|
The name is mangled, and your declaration cannot find it.
http://msdn.microsoft.com/mobility/...pbinpinvoke.asp -- Chris Tacke, eMVP Co-Founder and Advisory Board Member www.OpenNETCF.org --- Windows CE Product Manager Applied Data Systems www.applieddata.net "AkeK" <anonymous@discussions.microsoft.com> wrote in message news:E9BE8C4A-21BC-4A31-8EC1-D7E3DFF78187@microsoft.com... > > The dumpbin /exports give me: > 10 9 0000100F ?Msr3000_Open@@YAKPAG00PAX@Z > > It dont say me a thing! > > The following call give me "A managed InvalidCastException": > > <DllImport("msr8800.dll", CallingConvention:=CallingConvention.Winapi, _ > CharSet:=CharSet.Unicode, EntryPoint:="Msr3000_Open")> _ > Public Shared Function _ > Msr3000_OpenW(ByVal ptrSerialPort As Byte, ByVal ptrDllVersion As Byte, _ > ByVal ptrFirmwareVersion As Byte, ByVal pPortHandle As Byte) As UInt32 > End Function > > Public svar_open As UInt32 > Public svar_close As Int32 > Public szPort As String > Public szDll As String > Public szFirm As String > Public szDummy As String > > Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click > szPort = "COM1:" > svar = Form1.Msr3000_OpenW(szPort, szDll, szFirm, szDummy) > svar_open = Form1.Msr3000_OpenW(szPort, szDll, szFirm, szDummy) > > Another question: How do you write the right path on Pocket PC 2003 for msr8800.dll ? > |
|
|
|
#6 |
|
Guest
Posts: n/a
|
Hallo and thanks for all help
I havent solved it yet, but I going to try on wednesda Best regards Ã…ke |
|
|
|
#7 |
|
Guest
Posts: n/a
|
http://www.alexfeinman.com/download...c=MsrReader.zip
But you will be better off obtaining Symbol Mobility .NET SDK that contains predefined classes for MSR 3000 "AkeK" <anonymous@discussions.microsoft.com> wrote in message news:CA1CAA05-5495-4B89-9C71-85CD34E7BDB5@microsoft.com... > Hallo > I want to call an unmanaged dll, written in eMbedded Visual C++ 4.0 > from Visual Studio 2003 Visual Basic, for an application for Pocket PC 2003. > I have tried with "Public Declare Function MSR3000_Open Lib "msr8800.dll" (..." and with the DllImport-statement, > but the "MissingMethodException" occurs every time. > I dont know how to set/declare the parameters. > > The function-declaration in the dll: > > typedef DWORD RET_STATUS; > MSR8800_API RET_STATUS Msr3000_Open(TCHAR *ptrSerialPort, TCHAR *ptrDllVersion, > TCHAR *ptrFirmwareVersion, void *pPortHandle) > { > > I have a program written in eMbedded Visual C++ 4.0 and the call from that program looks like this: > > DWORD rs; > TCHAR szPort[] = _T("COM1:"); // Serial Port > TCHAR szDll[40]; // to receive version info > TCHAR szFirm[40]; // to receive firmware version > TCHAR szDummy[20]; // for unused parameters > rs = Msr3000_Open(szPort,szDll, szFirm, szDummy); > > Regards Åke |
|
|
|
#8 |
|
Guest
Posts: n/a
|
Thanks for the answer, I think this is what I need
Regards Ã…ke |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

