Platform: VB.Net 1.1
I am trying to pass a string in VB.Net to a C Dll method which accepts a
BSTR. I get a nullreference exception whenever I call the API.
The following VBA declaration works fine in my previous Application:
Dim ddl As String
...
set_DatafilePath (ddl)
...
Declare Sub set_DatafilePath Lib "mydll.dll" (ByVal datafilepath As String)
In VB.Net, I have tried following:
String path = "somepath"
set_DatafilePath (path)
a) Declare Sub set_DatafilePath Lib "mydll.dll" ( ByVal datafilepath As
String)
b) Declare Sub set_DatafilePath Lib "mydll.dll" (
<MarshalAs(UnmanagedType.BStr)> ByVal datafilepath As String)
c) <DllImport("mydll.dll", CharSet:=CharSet.Auto)> _ 'Have tried ANSI as
well as Unicode as well
Public Shared Sub set_DatafilePath(<MarshalAs(UnmanagedType.BStr)> ByVal
datafilepath As String)
End Sub
d) <DllImport("mydll.dll", CharSet:=CharSet.Auto)> _
Public Shared Sub set_DatafilePath( ByVal datafilepath As String)
End Sub
Any help would be appreciated.
Cheers,
Manish Jain
XXXX@XXXXX.COM