Re: NullReferenceException when passing structures by reference to a C API
- From: "Christian Ehlscheid" <christian.nospam@xxxxxx>
- Date: Thu, 19 May 2005 00:15:48 +0200
Hello,
i think you don't have to issue
> ADMIN_PROF admin_prof = new ADMIN_PROF();
cause Marshal.PtrTo.. will return a new object, so you're effectivly
overwriting the one you've created with "new"
to isolate the problem you may comment out some members of ADMIN_PROF struct
e.g.
[StructLayout(LayoutKind.Sequential)]
public struct ADMIN_PROF
{
[ MarshalAs( UnmanagedType.ByValTStr, SizeConst=NAME_LEN )]
public String login_name;
[ MarshalAs( UnmanagedType.ByValTStr, SizeConst=ORG_NAME_LEN )]
public String org_name;
[ MarshalAs( UnmanagedType.ByValTStr, SizeConst=NAME_LEN )]
public String printer;
[ MarshalAs( UnmanagedType.ByValTStr, SizeConst=NAME_LEN )]
public String business_unit;
public int warning_flag;
public int create_admin;
public int create_infra;
public int create_dns_rrs;
// [ MarshalAs( UnmanagedType.ByValTStr, SizeConst=20 )]
// public String max_gui_level;
// public CONTACT_LST personrec;
// public IntPtr access_lst;
}
then run the code, if it succeeds remove one comment and run again, and
repeat this until the error comes up again ..
then you'll know what member causes the Net marshaler to fail and we can
continue trying to find a working solution ..
Regards
Christian
.
- Follow-Ups:
- Re: NullReferenceException when passing structures by reference to a C API
- From: uzairkhan@xxxxxxxxx
- Re: NullReferenceException when passing structures by reference to a C API
- References:
- NullReferenceException when passing structures by reference to a C API
- From: uzairkhan
- Re: NullReferenceException when passing structures by reference to a C API
- From: Christian Ehlscheid
- Re: NullReferenceException when passing structures by reference to a C API
- From: uzairkhan@xxxxxxxxx
- Re: NullReferenceException when passing structures by reference to a C API
- From: Jared Parsons [MSFT]
- Re: NullReferenceException when passing structures by reference to a C API
- From: Christian Ehlscheid
- Re: NullReferenceException when passing structures by reference to a C API
- From: uzairkhan@xxxxxxxxx
- Re: NullReferenceException when passing structures by reference to a C API
- From: uzairkhan@xxxxxxxxx
- Re: NullReferenceException when passing structures by reference to a C API
- From: Christian Ehlscheid
- Re: NullReferenceException when passing structures by reference to a C API
- From: uzairkhan@xxxxxxxxx
- Re: NullReferenceException when passing structures by reference to a C API
- From: Christian Ehlscheid
- Re: NullReferenceException when passing structures by reference to a C API
- From: uzairkhan@xxxxxxxxx
- NullReferenceException when passing structures by reference to a C API
- Prev by Date: Re: NullReferenceException when passing structures by reference to a C API
- Next by Date: Re: Calling into C DLL : passing structure with pointers
- Previous by thread: Re: NullReferenceException when passing structures by reference to a C API
- Next by thread: Re: NullReferenceException when passing structures by reference to a C API
- Index(es):
Relevant Pages
|