[Mono-list] Re: Java VM for .NET
Jeroen Frijters
mono@jeroen.nu
Fri, 21 Jun 2002 16:53:11 +0200
This is a multi-part message in MIME format.
------=_NextPart_000_0069_01C21944.20819930
Content-Type: text/plain;
charset="US-ASCII"
Content-Transfer-Encoding: 7bit
When writing a test case, I encountered another missing feature. This is
with mono4windows (0.12-20-6-2002). When I run the attached code it
says:
Before CreateType
Before Invoke
(process:3972): ** WARNING **: unhandled exception
System.NotImplementedException: "The requested feature is not yet
implemented"
in <0x00032> System.Reflection.Emit.TypeBuilder:GetMethodImpl
(string,System.Reflection.BindingFlags,System.Reflection.Binder,System.R
eflection.CallingConventions,System.Type[],System.Reflection.ParameterMo
difier[])
in <0x0006a> System.Type:GetMethod (string)
in <0x002d4> .Test:Main ()
RESULT: -1
I haven't yet submitted a bug, should this go under runtime or BCL?
Regards,
Jeroen
> -----Original Message-----
> From: mono-list-admin@ximian.com
> [mailto:mono-list-admin@ximian.com] On Behalf Of Paolo Molaro
> Sent: Friday, June 21, 2002 14:42
> To: 'Mono'
> Subject: Re: [Mono-list] Re: Java VM for .NET
>
>
> On 06/21/02 Jeroen Frijters wrote:
> > BTW, the latest build I tried (beginning June) didn't yet
> support the
> > AppDomain.TypeResolve event that I use, so I haven't been
> able to run my
> > code on Mono.
>
> If you file a bug with a test case for what it should do, you have
> greater chances to have someone fix it.
>
> lupus
>
> --
> -----------------------------------------------------------------
> lupus@debian.org debian/rules
> lupus@ximian.com Monkeys do it better
>
> _______________________________________________
> Mono-list maillist - Mono-list@ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
------=_NextPart_000_0069_01C21944.20819930
Content-Type: text/plain;
name="Class1.cs"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="Class1.cs"
using System;
using System.Reflection;
using System.Reflection.Emit;
class Test=20
{
private static AssemblyBuilder assemblyBuilder;
private static ModuleBuilder moduleBuilder;
private static TypeBuilder lazyType;
private static MethodBuilder lazyMethod;
public static void Main()=20
{
AppDomain.CurrentDomain.TypeResolve +=3D new =
ResolveEventHandler(MyResolver);
AssemblyName name =3D new AssemblyName();
name.Name =3D "MyDynamicAssembly";
assemblyBuilder =3D =
AppDomain.CurrentDomain.DefineDynamicAssembly(name, =
AssemblyBuilderAccess.Run);
moduleBuilder =3D =
assemblyBuilder.DefineDynamicModule("MyDynamicModule");
lazyType =3D moduleBuilder.DefineType("LazyType");
lazyMethod =3D lazyType.DefineMethod("lazyMethod", =
MethodAttributes.Public | MethodAttributes.Static, typeof(void), =
Type.EmptyTypes);
TypeBuilder typeBuilder =3D moduleBuilder.DefineType("MyDynamicType");
MethodBuilder methodBuilder =3D typeBuilder.DefineMethod("method", =
MethodAttributes.Public | MethodAttributes.Static, typeof(void), =
Type.EmptyTypes);
ILGenerator ilGenerator =3D methodBuilder.GetILGenerator();
// NOTE: when this method is JITted the AppDomain.TypeResolve event =
should fire
ilGenerator.Emit(OpCodes.Call, lazyMethod);
ilGenerator.Emit(OpCodes.Ret);
Console.WriteLine("Before CreateType");
Type type =3D typeBuilder.CreateType();
Console.WriteLine("Before Invoke");
type.GetMethod("method").Invoke(null, new object[0]);
}
private static Assembly MyResolver(object sender, ResolveEventArgs =
args)=20
{
Console.WriteLine("TypeResolve {0}", args.Name);
if(args.Name =3D=3D "LazyType")
{
ILGenerator ilGenerator =3D lazyMethod.GetILGenerator();
ilGenerator.EmitWriteLine("Running lazy method");
ilGenerator.Emit(OpCodes.Ret);
lazyType.CreateType();
return assemblyBuilder;
}
return null;
}
}
------=_NextPart_000_0069_01C21944.20819930--