problems with parameter handover insection marshaling/ P/Invoke

E

Elmar Jacobs

hi folk,

i work with c# and eVC4.2. In eVC I have a ComInterface.dll whitch is using
from the c# dllTest program for a smart device application. It seems so that
I have a problem with the number of hand over parameter. The problematic
export function is SWI with 13 parameters.

comInterface.cpp
void __declspec(dllexport) SWI(int rbp, int rdi, int rsi, int rds, int
res, int rdx, int rcx, int rbx, int rax, int rip, int rcs, int flags, int
port)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
// i do at time really nothing
}

comInterface.h
void __declspec(dllexport) SWI(int rbp, int rdi, int rsi, int rds, int
res, int rdx, int rcx, int rbx, int rax, int rip, int rcs, int flags, int
port);



dllTest.cs
{
MainForm(){
...
[DllImport("ComInterface.dll", EntryPoint = "SWI")]
extern static void SWI(int rbp, int rdi, int rsi, int rds, int res,
int rdx, int rcx, int rbx, int rax, int rip, int rcs, int flags, int port);
......
int rbp =1, rdi =2, rsi =3, rds =4, res =5, rdx =6, rcx =7, rbx =8,
rax =9, rip =10, rcs =11;
int flags =0;
int port =0;
rax = 200;
SWI(rbp, rdi, rsi, rds, res, rdx, rcx, rbx, rax, rip, rcs, flags,
port);
}
}


if I remove the port parameter all works very well, but if i include the
port parametr i become the error msg

"An unhandled exception of type 'System.ArgumentException' occurred in
dllTest.exe"

Can somebody explain me that behavior?

With best thanks,
elmar
 
A

Alex Yakhnin [MVP]

I beleive there's a limit (12?) on the number of parameters you can in the
P/Invoke in CF.
Change it to pass a struct instead.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top