[Mono-list] mcs exception with const strings
Dwivedi , Ajay Kumar
AjayKumar.Dwivedi@WebtekSoftware.com
Thu, 25 Jul 2002 23:25:00 +0530
Hi all,
I think I have found out the cause of this exception, but don't know
how to fix it.
This exception occurs during compilaton with mcs, whenever we try to access
a const string field of a class in another assembly. The compilation works
file for other types, eg. const int.
In mono_class_vtable function in mono/metadata/object.c, line 244, case
MONO_TYPE_STRING does nothing. If I am correct, this is the place where
values of const fields of objects in other assemblies are loaded. Because of
this, A null value is stored in the StringConstant which later gives rise to
this exception.
Happy Hacking,
Ajay
>Hi All
> The following code throws an exception when compiling on linux.
>
>using System;
>public class A
>{
> public static void Main()
> {
> string str = System.Xml.Schema.XmlSchema.Namespace;
> }
>}
>
>The error is :
>
>** (process:15274): WARNING **: unhandled exception
>System.NullReferenceException: "A null value was found where an object
instance
>was required"
>in (unmanaged) System.Reflection.Emit.AssemblyBuilder:getUSIndex ()
>in <0x00016> System.Reflection.Emit.ILGenerator:Emit
>(System.Reflection.Emit.OpCode,string)
>in <0x00037> Mono.CSharp.StringConstant:Emit (Mono.CSharp.EmitContext)
>in <0x00046> Mono.CSharp.LocalVariableReference:EmitAssign
>(Mono.CSharp.EmitContext,Mono.CSharp.Expression)
>in <0x0012a> Mono.CSharp.Assign:Emit (Mono.CSharp.EmitContext,bool)
>in <0x00015> Mono.CSharp.Assign:EmitStatement (Mono.CSharp.EmitContext)
>in <0x00078> Mono.CSharp.StatementExpression:Emit (Mono.CSharp.EmitContext)
>in <0x0023f> Mono.CSharp.Block:Emit (Mono.CSharp.EmitContext)
>in <0x000ac> Mono.CSharp.EmitContext:EmitTopBlock
>(Mono.CSharp.Block,Mono.CSharp.Location)
>in <0x00403> Mono.CSharp.Method:Emit (Mono.CSharp.TypeContainer)
>in <0x001df> Mono.CSharp.TypeContainer:Emit ()
>in <0x004c3> Mono.CSharp.RootContext:EmitCode ()
>in <0x018e6> Mono.CSharp.Driver:MainDriver (string[])
>in <0x0000b> Mono.CSharp.Driver:Main (string[])
>
>Namespace is defined in System.Xml.Schema.XmlSchema class as const string.
>Is this a bug or something TODO?
>
>Happy Hacking,
>Ajay
>