LPSTR -> String : Type Incompatibility Issue
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.vc.

Post a new message to this list...

Michael Chong
Another same issue on "NullReferenceException" :-
I have an (exe) executable program created in VB.NET 2003 that calls to a
MFC DLL written in VC++.NET 2003. I always get an error msg
"NullReferenceException: Object Reference Not Set to an Instance of an
Object" when my exe calls the following codes:

in VB.NET

Declare Function test Lib "C:\Cyob\IOComm\Debug\IOComm.dll" _
(ByVal a As Long, ByRef b As String) As Integer

Dim did As Integer
Dim ret As Integer

ret = test(PortHnd, did) //ERROR: Object Reference Not Set to an
Instance of an Object

in VC++.NET

extern "C" int APIENTRY test(HANDLE a, LPSTR b)
{
strcpy(b, "hello"); //ERROR: Object Reference Not Set to an
Instance of an Object
return 99;
}

Why is this happening? Any idea in solving such matter?
Thanks in Advance

Michael.

Reply to this message...
 
    
Michael Chong
Sorry, the "Dim did as Integer" should be "Dim did as String"
I believe is DataType issue from VC++.NET (LPSTR) pass to VB.NET (String)

When I try to replace String with IntPtr, it doesn't give me error but the
return value for "did variable" is some numbers.
Plz help! TQ

"Michael Chong" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.IntPtr
System.NullReferenceException




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com