M
Mike
I am wondering what i need to do here in my VB.NET class library.
Overall, the error I am getting is this:
DLLIMPort PInvoke restriction: cannot return variants.
I'm open to changing code. This is what I have now that works under VB6.
Declare Function GetAccessProfileNames _
Lib "wcvb.dll" Alias "vbGetAccessProfileNames" () As Variant
The wcvb.dll wrapper library has this for the function:
VARIANT APIENTRY vbGetAccessProfileNames()
{
VARIANT v;
VariantInit(&v);
int count = GetAccessProfileCount();
TSecurityName *names = new TSecurityName[count];
if (!GetAccessProfileNames(count, names)) {
delete []names;
return v;
}
GetStringArray(v, names[0], SIZE_SECURITY_NAME, count);
delete []names;
return v;
}
and in VB6, it can be uses as
Dim names As Variant
names = GetAccessProfileNames()
For the class library, I have:
<DllImport("wcvb.dll", EntryPoint:="vbGetAccessProfileNames",
SetLastError:=True)>
Public Shared Function GetAccessProfileNames() As Object
End Function
Using it
Dim alist as Object = GetAccessProfileNames()
yields the PInvoke restriction: cannot return variants.
I tried other combinations like:
<DllImport("wcvb.dll", EntryPoint:="vbGetAccessProfileNames",
SetLastError:=True)>
Public Shared Function GetAccessProfileNames() As TSecurityName()
End Function
And I get a Exception:
Cannot marshal 'return value': Invalid managed/unmanaged type
combination.
How should I do this with VB.NET?
Thanks
--
Overall, the error I am getting is this:
DLLIMPort PInvoke restriction: cannot return variants.
I'm open to changing code. This is what I have now that works under VB6.
Declare Function GetAccessProfileNames _
Lib "wcvb.dll" Alias "vbGetAccessProfileNames" () As Variant
The wcvb.dll wrapper library has this for the function:
VARIANT APIENTRY vbGetAccessProfileNames()
{
VARIANT v;
VariantInit(&v);
int count = GetAccessProfileCount();
TSecurityName *names = new TSecurityName[count];
if (!GetAccessProfileNames(count, names)) {
delete []names;
return v;
}
GetStringArray(v, names[0], SIZE_SECURITY_NAME, count);
delete []names;
return v;
}
and in VB6, it can be uses as
Dim names As Variant
names = GetAccessProfileNames()
For the class library, I have:
<DllImport("wcvb.dll", EntryPoint:="vbGetAccessProfileNames",
SetLastError:=True)>
Public Shared Function GetAccessProfileNames() As Object
End Function
Using it
Dim alist as Object = GetAccessProfileNames()
yields the PInvoke restriction: cannot return variants.
I tried other combinations like:
<DllImport("wcvb.dll", EntryPoint:="vbGetAccessProfileNames",
SetLastError:=True)>
Public Shared Function GetAccessProfileNames() As TSecurityName()
End Function
And I get a Exception:
Cannot marshal 'return value': Invalid managed/unmanaged type
combination.
How should I do this with VB.NET?
Thanks
--