Herby said:
Perhaps I am being misunderstood.
If i compile the module containing my native class with \clr, then
within my native methods i can create and use managed types, by
default. This gives me mixed mode type functionality, which is what i
require.
I only want to do this within one of the methods of my native class.
I want the remainder methods to remain native. They have no need to
access managed types.
But a method in a native class must be a native method, it can't be a
managed method. You aren't fully understanding the meaning of mixed mode I
guess. Mixed mode means that you can have native classes and managed classes
in the same compilation unit, but you can't have native member functions in
managed classes, nor can you have managed methods as members of native
classes. The reason is the fundamental difference between the managed object
model and the unmanaged object model.
So for all the other methods i would then have to precede them with
#pragma unmanaged to ensure they stay native given the module has been
compiled \clr.
The pragma can be a pplied anywhere except inside a class definition.
#pragma unmanaged
class MyClass
{
public:
void MyNativeMethod(); //must be a native function
int i;
...
}
#pragma managed
ref class MyRefClass
{
public:
void MyManagedMethod(); //must be a managed function
int i;
};
In above sample MyNativeMethod will be compiled as native code, the class
instance will be stored in the process heap.
MyManagedMethod will be compiled as managed code and the instance of the
class will end on the GC heap.
This is alot of editing, i just want to do the inverse.
Default to compiling them native unless you hit #pragma managed.
Not sure why you wan't some classes to be unmmanaged while others should be
managed, anyway if you compile your program with /clr without any pragma
unmanaged in the compiland, all code will be compiled to IL, will all data
members an the object instances will be treated as native objects.
And this is what is basically mixed mode.
I dont see the point in #pragma managed if it can only be used within a
module compiled with \clr?
Don't get this one, sorry.
Willy.