|
-
Calling unmanaged C DLL function with char args
Ok,
I have a problem with VB.NET calling an unmanaged VC 6.0 C DLL from a form
that has char * args. The function prototype for the particular C function
in the C DLL is:
long _stdcall srv_binary_dxf_pntbat(char *inputname, char *dxfname, char
*cmdfile)
I have many other functions in this DLL that I call from my form with double
and integer args with NO problems whatsoever. Its the char/string stuff that
is giving me fits. In VB6 I use the following Declare:
'For using my 'C' dll
Public Declare Function srv_binary_dxf_pntbat Lib "srvm20.dll" (ByVal sBCGOfile
_
As String, ByVal sDXFfile As String, ByVal sCMDfile As String) As Long
It works fine in VB6.
I have tried passing the VB.NET args as byte arrays(ByRef and ByVal) with
a terminating NULL char with no luck at all - I have tried marshaling the
args with my declare in a module like this:
Public Declare Ansi Function srv_binary_dxf_pntbat Lib "srvm20.dll" _
(<MarshalAs(UnmanagedType.LPStr)> ByVal sBCGOfile As String, _
<MarshalAs(UnmanagedType.LPStr)> ByVal sDXFfile As String, _
<MarshalAs(UnmanagedType.LPStr)> ByVal sCMDfile As String) As Integer
In my VB.NET form I call this function like so - all args are the correct
type:
lRx = srv_binary_dxf_pntbat(sBDA, sDXF, sCMD)
No matter what I do, it errors with err.number=91 with an error message of
"Object Reference Not set to an instance of an object"
I am just learning .NET and it has been a shall we say a "challenge" for
me. It is so different from VB6 its almost overwhelming - I am determined
to get better at this coding but can one of you wizards help me over this
hump?
Thanks in advance,
Terry
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks