[Mono-list] NullReferenceException in rootcontext.cs
Brian Jepson
bjepson@oreilly.com
Sun, 16 Sep 2001 16:12:20 -0400 (EDT)
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.
---559023410-851401618-1000671140=:2653
Content-Type: TEXT/PLAIN; charset=US-ASCII
Hi,
I downloaded, compiled, and installed the September 15 snapshot, and tried
to compile the following (foo.cs):
using System;
class foo {
public static void Main() {
Console.WriteLine("Hello, World");
}
}
with this command:
compiler.exe -L /usr/local/lib foo.cs
But I got an exception:
Unhandled Exception: System.NullReferenceException: Value null was found
where an instance of an object was required.
at CIR.RootContext.IsNamespace(String name) in
c:\bjepson\src\mono-15-Sep-01\mcs\mcs\rootcontext.cs:line 568
...
The attached patch fixes this problem for me, by enclosing the offending
line in a try...catch block. Once I did that, I had a foo.exe that runs
great and looks very nice with ILDASM. Great work - this is very nice to
see!
Cheers,
Brian
---559023410-851401618-1000671140=:2653
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="patch.txt"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.GSO.4.21.0109161612200.2653@sol.east.ora.com>
Content-Description:
Content-Disposition: attachment; filename="patch.txt"
KioqIHJvb3Rjb250ZXh0LmNzCUZyaSBTZXAgMTQgMjM6NDc6MTQgMjAwMQ0K
LS0tIHJvb3Rjb250ZXh0LmNzLWJqZXBzb24JU3VuIFNlcCAxNiAxNjowMzo0
OCAyMDAxDQoqKioqKioqKioqKioqKioNCioqKiA1NjUsNTcxICoqKioNCiAg
DQogIAkJcHVibGljIGJvb2wgSXNOYW1lc3BhY2UgKHN0cmluZyBuYW1lKQ0K
ICAJCXsNCiEgCQkJTmFtZXNwYWNlIG5zID0gKE5hbWVzcGFjZSkgdHJlZS5O
YW1lc3BhY2VzIFtuYW1lXTsNCiAgDQogIAkJCWlmIChucyAhPSBudWxsKQ0K
ICAJCQkJcmV0dXJuIHRydWU7DQotLS0gNTY1LDU3NiAtLS0tDQogIA0KICAJ
CXB1YmxpYyBib29sIElzTmFtZXNwYWNlIChzdHJpbmcgbmFtZSkNCiAgCQl7
DQohIAkJCU5hbWVzcGFjZSBuczsNCiEgICAgICAgICAgICAgICAgICAgICAg
ICAgdHJ5IHsNCiEgCQkJICBucyA9IChOYW1lc3BhY2UpIHRyZWUuTmFtZXNw
YWNlcyBbbmFtZV07DQohICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0
Y2ggew0KISAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxz
ZTsNCiEgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICANCiAgCQkJaWYg
KG5zICE9IG51bGwpDQogIAkJCQlyZXR1cm4gdHJ1ZTsNCg==
---559023410-851401618-1000671140=:2653--