Chris Gagnon
2009-12-15 03:02:12 UTC
Consider this C# library
namespace MyLib
<System.Reflection.Assembly object at 0x0435AE50>
<System.Reflection.Assembly object at 0x0435AE90>
<System.Reflection.Assembly object at 0x044F9B10>
<System.Reflection.Assembly object at 0x02A95390>
Ready to go!
Yeah all worked fine!
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
System.Exception: Deprecated constructor.
at MyLib.CXDoc..ctor()
What happened! Well inside the constructor it hit an file not found
exception of some such.
Can someone explain why it hides that from me and calls the default
constructor and shows me that exception.
This seems like an unintuitive thing to do, and has made debugging a huge
pain.
-Chris
namespace MyLib
{
public class CXDoc
{
// Construction
public CXDoc(string sPath)
{
XmlDocument oDoc = new XmlDocument();
oDoc.Load(sPath);
}
public CXDoc()
{
throw new Exception("Deprecated constructor.");
}
}
}
Now this scriptpublic class CXDoc
{
// Construction
public CXDoc(string sPath)
{
XmlDocument oDoc = new XmlDocument();
oDoc.Load(sPath);
}
public CXDoc()
{
throw new Exception("Deprecated constructor.");
}
}
}
import clr
clr.AddReference("System")
clr.AddReference("System")
from System import *
clr.AddReference("System.Data")
clr.AddReference("System.Data")
from System.Data import *
clr.AddReference("System.Xml")
clr.AddReference("System.Xml")
from System.Xml import *
clr.AddReference("MyLib")
clr.AddReference("MyLib")
import MyLib
from MyLib import *
from MyLib import *
testI1 = MyLib.CXDoc("path that does exist")
testI2 = MyLib.CXDoc("path that dosn't exist")
File "<stdin>", line 1, in <module>
System.Exception: Deprecated constructor.
at MyLib.CXDoc..ctor()
What happened! Well inside the constructor it hit an file not found
exception of some such.
Can someone explain why it hides that from me and calls the default
constructor and shows me that exception.
This seems like an unintuitive thing to do, and has made debugging a huge
pain.
-Chris