More on Emitting Multi Dimentional Arrays

time to read 10 min | 1820 words

Here is a small code sample that demonstrate the problem. This doesn't work, but changing the Run method parameter to anything but a multi dimentional array does work.

public interface WithMatrix


       void Run(int[,] matrix);



class Program


       static void Main(string[] args)


              AssemblyName assemblyName = new AssemblyName("test");

              AssemblyBuilder assemblyBuilder = AppDomain.CurrentDomain


              ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("myModule");

              TypeBuilder typeBuilder = moduleBuilder.DefineType("Neo", TypeAttributes.Class);


              MethodBuilder methodBuilder = typeBuilder.DefineMethod("Run",

                         MethodAttributes.Public | MethodAttributes.Virtual,typeof(void), new Type[]{typeof(int[,])});


              Type type = typeBuilder.CreateType();