471,570 Members | 1,007 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,570 software developers and data experts.

the dismatching error with "unsafe"

i need to use the native code(unmanaged code),and i have to use
void*,so i use the "unsafe" symbol then i meet the trouble

c++code:

SC_InitAsk sca;
memset(&sca, 0, sizeof(sca));
sca.m_Head.m_nType = SC_INIT;
sca.m_dwSoftware = 0x12345678;
sca.m_hWnd = m_hWnd;

m_Dll.SCInit(&sca, sizeof(sca)
c# code:

unsafe
{
SC_InitAsk sca = new SC_InitAsk();
sca.m_Head.m_lIndex = PublicValue.SC_INIT;
sca.m_dwSoftware = 0x12345678;
sca.m_hWnd = this.Handle;

SCInit(&sca, sizeof(SC_InitAsk));
}

c++ interface:
BOOL WINAPI SCInit(void *pInit, int nSize);

c# reference definition:
public unsafe static extern bool SCInit(void* pInit, int nSize);

---------
my trouble:
when debug c#,i got dismatching error with the c++ interface,then i
can't find out what's wrong,for the reason may be the struct definition
or the "void *"

so how i can work it out ,or how i can debug this?

Feb 10 '06 #1
2 1629
Why can't you use PInvoke?

--

Stoitcho Goutsev (100)

<sh***********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
i need to use the native code(unmanaged code),and i have to use
void*,so i use the "unsafe" symbol then i meet the trouble

c++code:

SC_InitAsk sca;
memset(&sca, 0, sizeof(sca));
sca.m_Head.m_nType = SC_INIT;
sca.m_dwSoftware = 0x12345678;
sca.m_hWnd = m_hWnd;

m_Dll.SCInit(&sca, sizeof(sca)
c# code:

unsafe
{
SC_InitAsk sca = new SC_InitAsk();
sca.m_Head.m_lIndex = PublicValue.SC_INIT;
sca.m_dwSoftware = 0x12345678;
sca.m_hWnd = this.Handle;

SCInit(&sca, sizeof(SC_InitAsk));
}

c++ interface:
BOOL WINAPI SCInit(void *pInit, int nSize);

c# reference definition:
public unsafe static extern bool SCInit(void* pInit, int nSize);

---------
my trouble:
when debug c#,i got dismatching error with the c++ interface,then i
can't find out what's wrong,for the reason may be the struct definition
or the "void *"

so how i can work it out ,or how i can debug this?

Feb 10 '06 #2
What do you mean with a "dismatching error"?

Willy.

<sh***********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
|i need to use the native code(unmanaged code),and i have to use
| void*,so i use the "unsafe" symbol then i meet the trouble
|
| c++code:
|
| SC_InitAsk sca;
| memset(&sca, 0, sizeof(sca));
| sca.m_Head.m_nType = SC_INIT;
| sca.m_dwSoftware = 0x12345678;
| sca.m_hWnd = m_hWnd;
|
| m_Dll.SCInit(&sca, sizeof(sca)
|
|
| c# code:
|
| unsafe
| {
| SC_InitAsk sca = new SC_InitAsk();
| sca.m_Head.m_lIndex = PublicValue.SC_INIT;
| sca.m_dwSoftware = 0x12345678;
| sca.m_hWnd = this.Handle;
|
| SCInit(&sca, sizeof(SC_InitAsk));
| }
|
| c++ interface:
| BOOL WINAPI SCInit(void *pInit, int nSize);
|
| c# reference definition:
| public unsafe static extern bool SCInit(void* pInit, int nSize);
|
| ---------
| my trouble:
| when debug c#,i got dismatching error with the c++ interface,then i
| can't find out what's wrong,for the reason may be the struct definition
| or the "void *"
|
| so how i can work it out ,or how i can debug this?
|
Feb 10 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Markus Elfring | last post: by
40 posts views Thread by Steve Juranich | last post: by
3 posts views Thread by Stephen Gennard | last post: by
5 posts views Thread by Stuart | last post: by
3 posts views Thread by tlemcenvisit | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by Vinnie | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.