473,499 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

c++/cli method signature limitation

Anybody know what the "internal limitation" of a method signature is
for c++/cli?

I've got a mixed assembly that throws an exception for one particular
function (very large if-else control). It throws a
System.Runtime.InteropServices.MarshalDirectiveExc eption with the
additional information "Internal limitation: method signature is too
complex or too large." When I compile the function as native, no
problem.

TIA,
Sharon

May 10 '06 #1
10 1576
Hi Sharon
"dotnetchic" <do********@gmail.com> wrote in message
news:11**********************@q12g2000cwa.googlegr oups.com...
Anybody know what the "internal limitation" of a method signature is
for c++/cli?

I've got a mixed assembly that throws an exception for one particular
function (very large if-else control). It throws a
System.Runtime.InteropServices.MarshalDirectiveExc eption with the
additional information "Internal limitation: method signature is too
complex or too large." When I compile the function as native, no
problem.

TIA,
Sharon


This looks like a very interesting bug.
Can you please tell me what the CallStack of the MarshalDirectiveException
gives you?
Can you please tell me the signature of the critical function?

Marcus
May 11 '06 #2
Well, let's see...

method signature (open file method) looks like this:
int foo(FILE *file1, FILE *file2, CUSTOMSTRUCT1 custom1, CUSTOMSTRUCT2
custom2, unsigned short parm5, unsigned short parm6, unsigned short
parm7, int parm8, unsigned short &parm9)
{
// function body = 1800+ lines, roughly 1550 lines of executable code
}

and the call stack at the point the exception is thrown is:
KERNEL32.DLL!7c81eb33()
[Frames below may be incorrect and/or missing, no symbols loaded for
KERNEL32.DLL]
KERNEL32.DLL!7c81eb33()
MyApp.exe!foo(...)
[External Code]
MyApp.exe!OnFileOpen() Line 949 + 0x35 bytes
[External Code]
(... then several calls into mfc80d.dll for messaging ...)

May 11 '06 #3
"dotnetchic" wrote:
method signature (open file method) looks like this:
int foo(FILE *file1, FILE *file2, CUSTOMSTRUCT1 custom1, CUSTOMSTRUCT2
custom2, unsigned short parm5, unsigned short parm6, unsigned short
parm7, int parm8, unsigned short &parm9)
{
// function body = 1800+ lines, roughly 1550 lines of executable code
}


I would try passing pointers to the two custom structures instead of the
entire structures themselves to the function. While the marshaller should be
able to handle a 9-parameter function, it may be choking on the structures.

Sean
May 11 '06 #4
Well, this is a bit of legacy code that I'm not sure I want to modify.
I'll probably leave it compiled as unmanaged for now, and eventually
get around to re-writing it.

But I will test your hypothesis, once I figure out how...can we pass a
pointer in c++/cli? Don't we have to use IntPtr or something? ??

Thanks,
Sharon

May 11 '06 #5
That was easier than I thought. Pass pointers to the structs instead,
compile as managed, and it appears to run smoothly. Well, the program
crashes :( but it's beyond the scope of this thread.

cheers!

May 11 '06 #6
"dotnetchic" <do********@gmail.com> wrote in message
news:11*********************@i39g2000cwa.googlegro ups.com...
Well, this is a bit of legacy code that I'm not sure I want to modify.
I'll probably leave it compiled as unmanaged for now, and eventually
get around to re-writing it.
Just add a new file to the project that is compiled without /clr. Place the
function into this file. If necessay, you can also write a wrapper function
in this file, that passes all the arguments via one struct pointer or so.

In the file where you want to call the wapper function, just declare it is
usual.
But I will test your hypothesis, once I figure out how...can we pass a
pointer in c++/cli? Don't we have to use IntPtr or something? ??


No, you can work with pointers in C++/CLI, no need to use IntPtr.

Marcus

May 11 '06 #7
> Just add a new file to the project that is compiled without /clr. Place the
function into this file. If necessay, you can also write a wrapper function
in this file, that passes all the arguments via one struct pointer or so.


I've been using the #pragma unmanaged/managed keywords to delimit
native functions, but it looks like a lot of my native code will end up
residing in the same file, so I can in some cases compile the entire
file without /clr.

Is this a bad practice? Should I avoid using the #pragma unmanaged
keyword? I'd really hate to write wrappers for all these native
functions. I'm porting a very large codebase.

Sharon

May 11 '06 #8
Hi Sharon,

"dotnetchic" <do********@gmail.com> wrote in message
news:11**********************@j73g2000cwa.googlegr oups.com...
Just add a new file to the project that is compiled without /clr. Place
the
function into this file. If necessay, you can also write a wrapper
function
in this file, that passes all the arguments via one struct pointer or so.
I've been using the #pragma unmanaged/managed keywords to delimit
native functions, but it looks like a lot of my native code will end up
residing in the same file, so I can in some cases compile the entire
file without /clr.

Is this a bad practice? Should I avoid using the #pragma unmanaged
keyword?


It is a bad practice to use #pragma unmanaged. Native functions should end
up in cpp files compiled to native code and managed functions should end up
in cpp files compiled with /clr.
I'd really hate to write wrappers for all these native functions. I'm
porting a very large codebase.


There is no need to write wrappers.The only reason why you had to write one
wrapper frunction was because you reached the limits of P/Invoke
May 11 '06 #9
Duly noted. I suppose it does make more sense to have all the native
code residing in separate units. Many thanks, Marcus.
There is no need to write wrappers.The only reason why you had to write one
wrapper frunction was because you reached the limits of P/Invoke


Speaking of, is this limitation of P/Invoke documented anywhere? I've
been reading up on the usage of P/Invoke for a couple of weeks now, and
only in debugging did I discover this problem.

Sharon

May 11 '06 #10
"dotnetchic" <do********@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Duly noted. I suppose it does make more sense to have all the native
code residing in separate units. Many thanks, Marcus.
There is no need to write wrappers.The only reason why you had to write
one
wrapper frunction was because you reached the limits of P/Invoke


Speaking of, is this limitation of P/Invoke documented anywhere? I've
been reading up on the usage of P/Invoke for a couple of weeks now, and
only in debugging did I discover this problem.


After you have made me aware of this problem, it will likely be in the book
I am currently witing. Thanks for the info :-)
May 12 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1627
by: Cordell Lawrence | last post by:
Okay guys, We are wondering if this is a bug in Framework 2.0.40607 and looking for some clarification on the issue. Take a look at the folowing code. public delegate bool BoundryTest(int...
19
1912
by: Dave Raskin | last post by:
public class Base { } public class Derived : Base { } public class Service {
5
1107
by: Javaman59 | last post by:
eg. enum ButtonPress{Start, Stop, Pause}; void OnButtonPress(ButtonPress buttonPress) // <--- repetetive signature It looks a bit ugly, and I know some programmers who would go ballistic at...
5
2440
by: Simon Harris | last post by:
Hi All, I am trying to call a method in a web form, from an event fired in a user control. My user control displays a map, which has a link button to enlarge/shrink the map. When the user...
3
1518
by: Amin Sobati | last post by:
Hi, I have two classes. Class2 inhertis Class1: ----------------------------- Public Class Class1 Public Overridable Sub MySub() End Sub End Class Public Class Class2
6
2001
by: LordHog | last post by:
Hello all, I recently ran into a strange behavior which I don't understand. I have two 'Add' method which a slightly different signature which they look like public void Add( string varName,...
2
1482
by: Richard Jebb | last post by:
We are trying to use the API of a Win32 app which presents the API as a COM interface. The sample VB code for getting and setting the values of custom data fields on an object shows a method named...
9
5829
by: Steve Richter | last post by:
in a generic class, can I code the class so that I can call a static method of the generic class T? In the ConvertFrom method of the generic TypeConvert class I want to write, I have a call to...
5
1817
by: DamienS | last post by:
Hi, I have a static method in a class and I need to be able to return a reference to "this". Googling around, I found a heap of discussions of the pros/cons of "abstract static" etc. It was...
0
7131
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7174
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6894
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7388
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5470
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3099
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
297
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.