habuma
05-14-2005, 03:28 PM
I'm trying to recreate the Knight example from my book (http://http://www.amazon.com/exec/obidos/tg/detail/-/1932394354), this time using Spring.NET instead of the Java edition of Spring. But I'm running into some trouble early on.
To setup the problem, you should know that I'm compiling and running this on my MacOS X (Tiger), using Mono 1.1.7.
I have a simple appContext.xml file which looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<objects>
<object name="lancelot" type="Knight, Knight"/>
</objects>
And I have a KnightMain class that looks like this:
using Spring.Context;
using Spring.Context.Support;
public class KnightMain
{
public static void Main()
{
IApplicationContext ctx = new XmlApplicationContext("appContext.xml");
IKnight lancelot = (IKnight) ctx.GetObject("lancelot");
lancelot.embarkOnQuest();
}
}
And I have an IKnight interface and an implementation of IKnight called Knight (but I'll spare you the code...it's rather simple).
I compile all of this stuff into Knight.exe, thus the name of the assembly shold be "Knight", right? (I confirmed this by running monodis.)
It compiles fine...but when I run it, I get the following error:
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
in <0x000a4> System.Xml.XmlInputStream:Initialize (System.IO.Stream stream)
in (wrapper remoting-invoke-with-check) System.Xml.XmlInputStream:Initialize (System.IO.Stream)
in <0x00030> System.Xml.XmlInputStream:.ctor (System.IO.Stream stream)
in (wrapper remoting-invoke-with-check) System.Xml.XmlInputStream:.ctor (System.IO.Stream)
in <0x00044> System.Xml.XmlStreamReader:.ctor (System.IO.Stream input)
in (wrapper remoting-invoke-with-check) System.Xml.XmlStreamReader:.ctor (System.IO.Stream)
in <0x00044> System.Xml.XmlTextReader:.ctor (System.IO.Stream input)
in <0x0002c> System.Xml.Schema.XmlSchema:Read (System.IO.Stream stream, System.Xml.Schema.ValidationEventHandler validationEventHandler)
in <0x00108> Spring.Objects.Factory.Xml.XmlObjectDefinitionRead er:GetXmlReader (System.IO.Stream stream, Boolean validating)
in <0x00234> Spring.Objects.Factory.Xml.XmlObjectDefinitionRead er:LoadObjectDefinitions (IResource resource)
in <0x000c0> Spring.Context.Support.AbstractXmlApplicationConte xt:LoadObjectDefinitions (Spring.Objects.Factory.Xml.XmlObjectDefinitionRea der objectDefinitionReader)
in <0x000b0> Spring.Context.Support.AbstractXmlApplicationConte xt:RefreshObjectFactory ()
in <0x00150> Spring.Context.Support.AbstractApplicationContext: Refresh ()
in <0x0002c> Spring.Context.Support.XmlApplicationContext:.ctor (System.String[] configurationLocations)
in <0x00054> Spring.Context.Support.XmlApplicationContext:.ctor (System.String configurationLocation)
in <0x00038> KnightMain:Main ()
It seems that a NullReferenceException is getting thrown deep down in the bowels of the XML parser. But I can't figure out why. Does anyone have a clue? Am I doing something wrong or is this an issue with Mono?
[/code]
To setup the problem, you should know that I'm compiling and running this on my MacOS X (Tiger), using Mono 1.1.7.
I have a simple appContext.xml file which looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<objects>
<object name="lancelot" type="Knight, Knight"/>
</objects>
And I have a KnightMain class that looks like this:
using Spring.Context;
using Spring.Context.Support;
public class KnightMain
{
public static void Main()
{
IApplicationContext ctx = new XmlApplicationContext("appContext.xml");
IKnight lancelot = (IKnight) ctx.GetObject("lancelot");
lancelot.embarkOnQuest();
}
}
And I have an IKnight interface and an implementation of IKnight called Knight (but I'll spare you the code...it's rather simple).
I compile all of this stuff into Knight.exe, thus the name of the assembly shold be "Knight", right? (I confirmed this by running monodis.)
It compiles fine...but when I run it, I get the following error:
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
in <0x000a4> System.Xml.XmlInputStream:Initialize (System.IO.Stream stream)
in (wrapper remoting-invoke-with-check) System.Xml.XmlInputStream:Initialize (System.IO.Stream)
in <0x00030> System.Xml.XmlInputStream:.ctor (System.IO.Stream stream)
in (wrapper remoting-invoke-with-check) System.Xml.XmlInputStream:.ctor (System.IO.Stream)
in <0x00044> System.Xml.XmlStreamReader:.ctor (System.IO.Stream input)
in (wrapper remoting-invoke-with-check) System.Xml.XmlStreamReader:.ctor (System.IO.Stream)
in <0x00044> System.Xml.XmlTextReader:.ctor (System.IO.Stream input)
in <0x0002c> System.Xml.Schema.XmlSchema:Read (System.IO.Stream stream, System.Xml.Schema.ValidationEventHandler validationEventHandler)
in <0x00108> Spring.Objects.Factory.Xml.XmlObjectDefinitionRead er:GetXmlReader (System.IO.Stream stream, Boolean validating)
in <0x00234> Spring.Objects.Factory.Xml.XmlObjectDefinitionRead er:LoadObjectDefinitions (IResource resource)
in <0x000c0> Spring.Context.Support.AbstractXmlApplicationConte xt:LoadObjectDefinitions (Spring.Objects.Factory.Xml.XmlObjectDefinitionRea der objectDefinitionReader)
in <0x000b0> Spring.Context.Support.AbstractXmlApplicationConte xt:RefreshObjectFactory ()
in <0x00150> Spring.Context.Support.AbstractApplicationContext: Refresh ()
in <0x0002c> Spring.Context.Support.XmlApplicationContext:.ctor (System.String[] configurationLocations)
in <0x00054> Spring.Context.Support.XmlApplicationContext:.ctor (System.String configurationLocation)
in <0x00038> KnightMain:Main ()
It seems that a NullReferenceException is getting thrown deep down in the bowels of the XML parser. But I can't figure out why. Does anyone have a clue? Am I doing something wrong or is this an issue with Mono?
[/code]