[Mono-list] Embedding Mono .. problem with Console.WriteLine statement
Manish Gupta
GManish@novell.com
Tue, 22 Jun 2004 00:26:52 -0600
This is a MIME message. If you are reading this text, you may want to
consider changing to a mail reader or gateway that understands how to
properly handle MIME multipart messages.
--=__Part1233883C.0__=
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Hi,
I am able to invoke C# method from C and it work fine as long as the C#
method does not have Console.WriteLine() statement.
After introducing Console.Writeline() statement in C# function, the
result of invoking it from C was the following:
Unhandled Exception: System.TypeInitializationException: An exception
was thrown by the type initializer for System.Console --->
System.NullReferenceException: A null value was found where an object
instance was required
in [0x00000] (at
/cvs/mcs/class/corlib/System.Globalization/CultureInfo.cs:1096)
System.Globalization.CultureInfo:get_CurrentCulture ()
in [0x00001] (at /cvs/mcs/class/corlib/System/String.cs:673)
System.String:ToUpper ()
in [0x00016] (at /cvs/mcs/class/corlib/System/Console.cs:32)
System.Console:.cctor ()
--- End of inner exception stack trace ---
in (unmanaged) System.Console:WriteLine (string)
in <0x00017> TestNamespace.test:foo (string)
Can somebody provide a clue?
--=__Part1233883C.0__=
Content-Type: application/octet-stream; name="test.cs"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.cs"
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uSU87Cm5hbWVzcGFjZSBUZXN0TmFtZXNwYWNlCnsK
CXB1YmxpYyBjbGFzcyB0ZXN0Cgl7CgkJcHVibGljIHRlc3QoKQoJCXsKCQl9CgkJCgkJcHVibGlj
IHN0YXRpYyB2b2lkIGZvbyhTdHJpbmcgZmlsZU5hbWUpCQkJCgkJewoJCQlTdHJlYW1Xcml0ZXIg
c3cgPSBuZXcgU3RyZWFtV3JpdGVyKGZpbGVOYW1lLCB0cnVlKTsKCQkJc3cuV3JpdGUoIkhleSEg
d2hhdCdzIHVwIGR1ZGUiKTsKCQkJc3cuQ2xvc2UoKTsKCQl9CgoJfQp9Cg==
--=__Part1233883C.0__=
Content-Type: application/octet-stream; name="teste.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="teste.c"
I2luY2x1ZGUgPG1vbm8vbWluaS9qaXQuaD4KI2luY2x1ZGUgPG1vbm8vbWV0YWRhdGEvZW52aXJv
bm1lbnQuaD4KI2luY2x1ZGUgPG1vbm8vbWV0YWRhdGEvZGVidWctaGVscGVycy5oPgojaW5jbHVk
ZSA8bW9uby9tZXRhZGF0YS9sb2FkZXIuaD4KI2luY2x1ZGUgPG1vbm8vbWV0YWRhdGEvbW9uby1k
ZWJ1Zy5oPgoKc3RhdGljIE1vbm9Eb21haW4gKmRvbWFpbjsKc3RhdGljIE1vbm9Bc3NlbWJseSAq
YXNzZW1ibHk7CgovKgogKiBWZXJ5IHNpbXBsZSBtb25vIGVtYmVkZGluZyBleGFtcGxlLgogKiBD
b21waWxlIHdpdGg6IAogKiAJZ2NjIC1vIHRlc3RlIHRlc3RlLmMgYHBrZy1jb25maWcgLS1jZmxh
Z3MgLS1saWJzIG1vbm9gIC1sbQogKiAJbWNzIHRlc3QuY3MKICogUnVuIHdpdGg6CiAqIAkuL3Rl
c3RlIHRlc3QuZXhlCiAqLwpzdGF0aWMgdm9pZCBzZXR1cCgpCnsKCWFzc2VtYmx5ID0gbW9ub19k
b21haW5fYXNzZW1ibHlfb3Blbihkb21haW4sICJ0ZXN0LmRsbCIpOwoJaWYoYXNzZW1ibHk9PU5V
TEwpCgl7CgkJcHJpbnRmKCJjb3VsZCBub3QgbG9hZCBhc3NlbWJseVxuIik7CgkJbW9ub19lbnZp
cm9ubWVudF9leGl0Y29kZV9zZXQoLTEpOwoJfQoJZWxzZQoJewoJCXByaW50ZigiYXNzZW1ibHkg
bG9hZGVkIHN1Y2Nlc2Z1bGx5XG4iKTsKCQltb25vX2RlYnVnX2luaXRfMihhc3NlbWJseSk7CgkJ
ZG9tYWluLT5lbnRyeV9hc3NlbWJseT1hc3NlbWJseTsKCQltb25vX2Vudmlyb25tZW50X2V4aXRj
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