Dear All,

I created a dll with the following:

extern "C" _declspec(dllexport) int myFunction(A*){return a->myInt();}

class A{
    public:
        int i;
        int myInt(void){rerturn i;}
}

I creates a C# client with the folllowing:

public class MyClient{

    [DllImport("MyDll.dll")]
    public static extern in myFunction(A a);

    public static void Main(){

        A a = new A();
        a.i=5;
        Console.WriteLine(myFunction(a));
    }
}

[StructureLayout(LayputKind.Sequential)]
public class A{
        public int i;
        public int myInt(void){rerturn i;}
}


Why does this code work because most of the example I have seen is always using classes to mimic struct with no methods only fields?
 
How is the object marshalled?
 
I have readed .Net nad COM by Nathan/ COM and Net by Troelsen/MSND doc... there is no info on this matter. Where can I get more information on this subject?
 
What are the limites(inheritence,....) of redefining C+ classes in C# and call C++ code with the redefined classes?

James


P.s this code was tried with the microsoft's version of .Net

Reply via email to