PC Review


Reply
Thread Tools Rate Thread

Calling an unmanaged DLL from Visual Studio 2003 Visual Basic

 
 
=?Utf-8?B?QWtlSw==?=
Guest
Posts: n/a
 
      15th Mar 2004
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGFuaWVsIFBldGVyc3Nvbg==?=
Guest
Posts: n/a
 
      15th Mar 2004
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
 
Reply With Quote
 
=?Utf-8?B?QWtlSw==?=
Guest
Posts: n/a
 
      15th Mar 2004

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

 
Reply With Quote
 
Alex Yakhnin [MVP]
Guest
Posts: n/a
 
      15th Mar 2004
http://msdn.microsoft.com/mobility/p.../FAQ/default.a
spx#6.1

--
--
Alex Yakhnin .NET CF MVP
www.intelliprog.com | www.opennetcf.org

"AkeK" <(E-Mail Removed)> wrote in message
news:E9BE8C4A-21BC-4A31-8EC1-(E-Mail Removed)...
>
> 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 ?
>



 
Reply With Quote
 
Chris Tacke, eMVP
Guest
Posts: n/a
 
      15th Mar 2004
The name is mangled, and your declaration cannot find it.

http://msdn.microsoft.com/mobility/u...binpinvoke.asp

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net


"AkeK" <(E-Mail Removed)> wrote in message
news:E9BE8C4A-21BC-4A31-8EC1-(E-Mail Removed)...
>
> 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 ?
>



 
Reply With Quote
 
=?Utf-8?B?QWtlSw==?=
Guest
Posts: n/a
 
      15th Mar 2004
Hallo and thanks for all help
I havent solved it yet, but I going to try on wednesda
Best regards Ã…ke
 
Reply With Quote
 
Alex Feinman [MVP]
Guest
Posts: n/a
 
      15th Mar 2004
http://www.alexfeinman.com/download....=MsrReader.zip
But you will be better off obtaining Symbol Mobility .NET SDK that contains
predefined classes for MSR 3000

"AkeK" <(E-Mail Removed)> wrote in message
news:CA1CAA05-5495-4B89-9C71-(E-Mail Removed)...
> 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



 
Reply With Quote
 
=?Utf-8?B?QWtlSw==?=
Guest
Posts: n/a
 
      17th Mar 2004
Thanks for the answer, I think this is what I need
Regards Ã…ke
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to take an IE rendered screenshot of a website with visual studio .net 2002 or visual stuido .net 2003? I can't install visual studio .net 2005 on this computer. Daniel Microsoft C# .NET 0 14th May 2007 07:45 PM
VB.Net of Visual Studio.Net 2003 VS Visual Basic 2005 Express Edition hunkgym Microsoft VB .NET 1 22nd Oct 2006 02:55 PM
Visual Studio 2005 and Visual Basic .net 2003 Stewart Microsoft ASP .NET 1 24th Feb 2006 07:32 AM
Calling Unmanaged C++ functions from Visual Studio .NET C++ App David Lowndes Microsoft VC .NET 1 16th Feb 2006 04:21 PM
changing the visual basic in office 2003 to visual studio net =?Utf-8?B?YmlnZGFkZHkz?= Microsoft Excel Misc 1 13th Sep 2005 10:57 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:41 PM.