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 10 1558
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
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 ...)
"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
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
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!
"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
> 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
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
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
"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 :-) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
by: Dave Raskin |
last post by:
public class Base
{
}
public class Derived : Base
{
}
public class Service
{
|
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...
|
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...
|
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
|
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,...
|
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...
|
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...
|
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...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |