IRC Networks
Irc Logs Stats
Start date: 2007-09-27 02:48:27
Last update: 2008-04-02 18:00:08
Channels: 41
Logged Lines: 6229042
Size: 1806.44 MB
Powered by
Channel Info
Network: freenodeChannel: #csharp |
Search in www.irclog.org
Log from #csharp at freenode 2006-07-11
[00:01]<azyfm>whats a sandbox loading icon
[00:05]<d0`>never mind I don't care about that :)
[00:05]<d0`>i am still having trouble pinvoking some methods
[00:06]<d0`>HDAPI HDboolean HDAPIENTRY hdWaitForCompletion(HDSchedulerHandle hHandle,HDWaitCode param);
[00:07]<d0`>unsigned char HDboolean; unsigned long HDSchedulerHandle; unsigned int HDWaitCode;
[00:08]<d0`>i did this: public static extern bool hdWaitForCompletion(ulong hHandle, uint param);
[00:08]<d0`>A call to PInvoke function 'Haptic!Haptic.OpenHaptics.HD.HDScheduler::hdWaitForCompletion' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
[00:09]<d0`>it is complaining at this line: if (!HDScheduler.hdWaitForCompletion(hGravityWell, HDScheduler.HD_WAIT_CHECK_STATUS))
[00:11]<d0`>I really don't know why it is doing this
[00:14]<d0`>anyhelp is apprecieated
[00:20]<d0`>hmm Sytupid pinvoke, I had to use char
[00:20]<d0`>can't use boolean
[00:24]<d0`>I still did this: if (HDScheduler.hdWaitForCompletion(hGravityWell, HDScheduler.HD_WAIT_CHECK_STATUS) != '0')
[00:24]<d0`>where I changed the dllimport to be this: public static extern char hdWaitForCompletion(ulong hHandle, uint param);
[00:25]<d0`>I still get the PInvokeStackImbalance
[00:34]<22vnax>Can I use or reference something written in VB6 in C#.net?
[00:37]<awjzdd>bbtech: how does that make you feel as a person?
[00:38]<22vnax>hehe...HAPPY :D
[00:39]<lnvnzxu>bbtech: you'll have to use COM interop
[00:39]<awjzdd>bbtech: you should be able to reference a com dll from C# that was created in VB6
[00:39]<22vnax>ok, thanks
[00:42]<lnvnzxu>if the vb6 component is registered on the machine, you should find it under the COM tab in the Add Reference dialog; if the component is an ActiveX control, you should be able to add it to the toolbox as a ActiveX control and drag it to a design surface (a form, for example)
[00:44]<y-gz>how to marshal int * ?
[00:45]<y-gz>int xine_get_pos_length (xine_stream_t *stream, int *pos_time .... )
[00:47]<d0`>i-Nz it could be int[]
[00:47]<d0`>or IntPtr ?
[00:48]<y-gz>it can't be IntPtr
[00:48]<y-gz>well it can
[00:48]<y-gz>but i wonna read the value after that
[00:48]<d0`>i am having trouble with double *
[00:48]<d0`>peterhu may you please loook at this? http://pastebin.ca/84389
[00:49]<d0`>it is saying this: A call to PInvoke function 'Haptic!Haptic.OpenHaptics.HD.HDScheduler::hdWaitForCompletion' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
[00:49]<d0`>peterhu : could you see anythjing wrong from PInvoke function of hdWaitForCompletion
[00:49]<lnvnzxu>you didn't include the DllImport
[00:50]<d0`>it is included
[00:50]<lnvnzxu>in addition, I need to know what HDAPI and HDAPIENTRY are defined to
[00:50]<d0`>I just coppied and pasted the relevant information
[00:50]<d0`> [DllImport("hd", EntryPoint = "#33")]
[00:50]<d0`> public static extern char hdWaitForCompletion(ulong hHandle, uint param);
[00:50]<lnvnzxu>in this case, only the C signature and the DllImport are relevant
[00:50]<d0`>thats how I did it...
[00:50]<kjr>looks like I's goin to OSCon this yar
[00:50]<lnvnzxu>that will default to __stdcall calling convention
[00:50]<lnvnzxu>oh
[00:50]<lnvnzxu>one error
[00:51]<lnvnzxu>unsigned long is a uint in c#
[00:51]<lnvnzxu>more than likely your C/C++ long is 32-bit
[00:51]<y-gz>what about marshalling int * ?
[00:51]<d0`># define HDAPI __declspec(dllimport)
[00:51]<d0`># define HDAPIENTRY __stdcall
[00:51]<d0`># define HDCALLBACK __stdcall
[00:51]<lnvnzxu>i-nZ: what do you mean "read the value after that"?
[00:51]<d0`>Thats the stuff you were looking peterhu
[00:52]<lnvnzxu>m0`: ok, try changing the first parameter in hdWaitForCompletion to uint
[00:52]<lnvnzxu>(in the C# import)
[00:52]<d0`>okay
[00:53]<y-gz>peterhu: well int xine_get_pos_length (xine_stream_t *stream, int *pos_stream) -> that writes the stream position in pos_stream. I wonna get that value in my managed code
[00:53]<lnvnzxu>passing the int by ref should marshal it as an int*
[00:54]<y-gz>hmm
[00:54]<d0`>ah it works peterhu
[00:54]<lnvnzxu>m0`: cool
[00:54]<y-gz>i never really understood what does the "ref" does
[00:54]<d0`>Your amazing thank you
[00:54]<y-gz>as in... in managed everything is a pointer anyway
[00:54]<d0`>ref as in reference
[00:54]<y-gz>so a pointer to a pointer - but where can you use that?
[00:54]<lnvnzxu>i-nZ: value types aren't
[00:54]<d0`>peterhu now to my real problem, similar to i-NZ
[00:54]<y-gz>oh right ;)
[00:55]<d0`>peter;
[00:55]<d0`>HDAPI void HDAPIENTRY hdGetDoublev(HDenum pname, HDdouble *params);
[00:55]<d0`>I have been stuck at this for over 2 days
[00:56]<d0`>i did this: public static extern void hdGetDoublev(uint pname, ref double[] param);
[00:56]<lnvnzxu>whare are HDenum and HDdouble typeddef'd to
[00:56]<d0`>uint double respectively
[00:57]<d0`>typedef double HDdouble;typedef unsigned int HDenum;
[00:57]<lnvnzxu>how is the caller supposed to know how big a buffer to pass them to fill?
[00:57]<lnvnzxu>or how is the callee supposed to know how big the buffer is
[00:57]<d0`>i did a marshal of arraysize
[00:57]<y-gz>int xine_get_pos_length (xine_stream_t *stream, int *pos_stream, int *pos_time, int *length_time);
[00:57]<y-gz>private static extern int xine_get_pos_length (IntPtr stream, ref int pos_stream, ref int pos_time, ref int length);
[00:57]<y-gz>?
[00:57]<lnvnzxu>i mean, just from the C code; is there documentation somewhere that says the size?
[00:58]<d0`>its a vector of size 3
[00:58]<lnvnzxu>i-nZ: that should work
[00:58]<y-gz>peterhu: what about the [In,Out] stuff ?
[01:01]<lnvnzxu>i-nZ: on a value type, ref implies [in, out]; if you want in you would pass by value; if you want out, you'd use the out keyword
[01:01]<lnvnzxu>i'm not familiar with that function, so it's up to you for what's best
[01:02]<lnvnzxu>m0`: give me one sec
[01:02]<d0`>I am really confused
[01:03]<d0`>this is the C/C++ code: http://pastebin.ca/84402
[01:03]<d0`>this is the C# source: I did: http://pastebin.ca/84403
[01:04]<lnvnzxu>what's the typedef for hduVector3Dd?
[01:04]<d0`>the thing is that hduVector is just a Utility class
[01:05]<d0`>so I used the C# Vector Library
[01:05]<lnvnzxu>yes, but how is it getting passed to hdGetDoublev? is there a conversion operator?
[01:05]<d0`>yes
[01:05]<d0`>there is this:
[01:05]<d0`> /* Convert to array. */
[01:05]<d0`> operator const T*() const { return &m_p[0]; }







