Re: Help Porint C++ code to C#
- From: scottt <scottt@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 5 Nov 2005 22:21:01 -0800
IpSysCall is a function into a C++ DLL
I use import to use the function.
I don't think that IpSysCall is NULL since I call it several times
before it reaches this section of code.
Thank you.
"Pete Davis" wrote:
> Well, from the looks of it, IpSysCall is null. But you don't show the code
> relating to it, so I can't be positive.
>
> What is IpSysCall?
>
> Pete
>
>
> "scottt" <scottt@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:D4A92618-433D-4C16-AEA0-B44FE1E5682C@xxxxxxxxxxxxxxxx
> > Need help porting code.
> > I have a section of code that is getting an Null exception error
> > and I want to know if I have ported the function correctly.
> > The code works in C++ but when running the code in C# I get a
> > System.NullReferenceException.
> >
> >
> > Thanks,
> >
> >
> > C++ Code:
> >
> > typedef struct _VENDOR_CMD
> > {
> > BYTE bRequest;
> > WORD wValue;
> > WORD wIndex;
> > WORD wLength;
> > BYTE direction;
> > BYTE bData;
> > } VENDOR_CMD, *PVENDOR_CMD;
> >
> >
> > typedef struct _TT_SEND_VENDOR_CMD
> > {
> > VENDOR_CMD vcCmd;
> > DWORD dwDataSize;
> > PVOID pDataBuf;
> > } TT_SEND_VENDOR_CMD, *P_SEND_VENDOR_CMD;
> >
> >
> >
> > BOOL MyClass::myFunction(PVENDOR_CMD pRequest, DWORD dwDataSize, PVOID
> > pDataBuf)
> > {
> > TT_SEND_VENDOR_CMD ttCmd;
> > memcpy(&ttCmd.vcCmd, pRequest, sizeof(VENDOR_CMD));
> > ttCmd.dwDataSize = dwDataSize;
> > ttCmd.pDataBuf = pDataBuf;
> >
> > return(*pfnIpSysCall)(2, 0, &tjCmd);
> > } // End myFunction().
> >
> >
> >
> >
> >
> > C# Code:
> >
> >
> > struct VENDOR_CMD {
> > public byte bRequest;
> > public Int16 wValue;
> > public Int16 wIndex;
> > public Int16 wLength;
> > public byte direction;
> > public byte bData;
> > };
> >
> >
> > struct TT_SEND_VENDOR_CMD {
> > public VENDOR_CMD vcCmd;
> > public UInt32 dwDataSize;
> > public Int32 pDataBuf;
> > } ;
> >
> >
> > private bool myfuunction(VENDOR_CMD pRequest, UInt32 dwDataSize, ref byte
> > pDataBuf) {
> > bool returnCode = false;
> >
> > TT_SEND_VENDOR_CMD ttCmd;
> >
> > ttCmd.vcCmd = pRequest;
> > ttCmd.dwDataSize = dwDataSize;
> > ttCmd.pDataBuf = pDataBuf;
> > //
> > // Exception Here when calling function:
> > //
> > // An unhandled exception of type 'System.NullReferenceException' occurred
> > in tttest.exe
> > //
> > // Additional information: Object reference not set to an instance of an
> > object
> > //
> > returnCode = IpSysCall(2, 0, ref ttCmd);
> >
> > return(returnCode);
> > } // End myfunction().
> >
> >
> >
> >
> >
> >
> >
> >
>
>
>
.
- References:
- Help Porint C++ code to C#
- From: scottt
- Help Porint C++ code to C#
- Prev by Date: Re: path to sound file. how to remove "@" from file path? need "\\" instead.
- Next by Date: C# and python
- Previous by thread: Help Porint C++ code to C#
- Next by thread: Re: Help Porint C++ code to C#
- Index(es):