"Herby" <pr********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Iv compiled my current C++ project as \clr as i want to start putting
in some specific C++\CLI code to serialize my MFC objects to .NET
equivalents.
The program crashes on startup, something to do with the stack frame
being corrupted.
My first concern is the program has ballooned in terms of the size of
the executable image.
When it attempts to run it fails and some report about stack frame
corruption.
You should be specific: exactly how is it failing, exactly what is reported?
Iv noticed any C files have to be converted to C++.
Yes. You cannot compile C as managed code.
The program links to a DLL and Libs that have been compiled as C.
That's fine.
Is this a problem when compiling a program as /CLR that then links with
C libs etc and on startup loads C Dlls?
No, there's no problem with that. Consider that the operating system itself
is C and is exposed through DLLs...
How can i specifically instruct the compiler to only compiler specific
functions/methods as managed(mixed mode) and to leave everything else
as native?
See #pragma managed and #pragma unmanaged. You also can throw the /clr
compiler option only on files that contain managed code and continue to
compile everything else as native code. That might save you from having to
insert #pragma unmanaged a bunch of places.
Note that header files that define declarations that will be shared between
native and managed code should generally be written as:
// MySharedHeader.h
#pragma once
#pragma managed(push, off)
// your declarations here
#pragma managed(pop)
This will ensure that the declarations in the shared header are always seen
as unmanaged regardless of how the compilation unit the references the
header file is compiled.
Note also that preprocessor macros (#define) are neither managed nor
unmanaged - they're simply text substitutions, so they'll work identically
in either environment.
-cd