After making the changes as you suggest,
RASDIALPARAMS rdp = new RASDIALPARAMS();
rdp.dwSize = Marshal.SizeOf(rdp); returns a value of
2120.
We found that the "magic number" for it to work is to when
Marshal.SizeOf(rpd) is 2108.
Do you have any idea why?
Don't use classes for interop, use structures and check the structure
packing as used in the header files.
This:
[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Auto, Pack=4)]
public struct RASDIALPARAMS
{
public int dwSize=Marshal.SizeOf(typeof(RASDIALPARAMS));
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=256+1)]
public string szEntryName=null;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=128+1)]
public string szPhoneNumber=null;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=128+1)]
public string szCallbackNumber=null;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=256+1)]
public string szUserName=null;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=256+1)]
public string szPassword=null;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst=15+1)]
public string szDomain=null;
public int dwSubEntry=0;
public IntPtr dwCallbackId;
}
returns 2108 for dwSize.
Willy.