hpcd
02-17-2007, 06:29 AM
I am working on a Win Forms .NET 2.0 app and I'm using Spring to wire up the various classes.
Things were working well up to earlier today, but then I started getting the famous Context error. In an attempt to trace things, I'm stripped out almost all of the XML, except for the one for the main form that will launch in Program.cs. Here are some of the things I've found:
a) If the class has constructor and I try to inject, no problems..it works
b) As soon as I add a string Propertty to inject some static text, I get a error thrown in the class. The property isn't doing anything in the class-not even setting a text box. As soon as I comment out the property from the XML, things work.
Any ideas? I'm using Spring.NEt 1.0.2.
Here is a sample:
I added Form1 to the project:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace MyAssembly
{
public partial class Form1 : Form
{
public string MyText
{
set
{
// do nothing.
}
}
public Form1()
{
InitializeComponent();
}
}
}
This form doesn't have any controls (just added Form1 and added the property).
I'm using:
IApplicationContext appctx= new XmlApplicationContext(
"file://views.spring.cfg.xml"
);
Form mainForm = appctx.GetObject("appShellForm");
Application.Run(mainForm);
Using XmlApplicationContext, because the error messages are more detailed than if you use ContextRegistery and app.config handlers.
The XML is (views.spring.cfg.xml):
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.net
http://www.springframework.net/xsd/spring-objects.xsd" >
<object id="appShellForm" type="MyAssembly.Form1, MyAssembly">
<!--<property name="MyText" value="Set Me" />-->
</object>
</objects>
When I uncomment the property setter, I get the following error:
Error creating object with name 'appShellForm' defined in 'file [C:\todelete\MyAssembly\bin\Debug\views.spring.cfg. xml]' : Initialization of object failed : Could not load file or assembly 'antlr.runtime, Version=2.7.5.22, Culture=neutral, PublicKeyToken=65e474d141e25e07' or one of its dependencies. The system cannot find the file specified.
This is stumping me. The only thing left, is for me to create a brand new project and start adding files one by one. I'll probably try that and see. Thanks in advance.
Things were working well up to earlier today, but then I started getting the famous Context error. In an attempt to trace things, I'm stripped out almost all of the XML, except for the one for the main form that will launch in Program.cs. Here are some of the things I've found:
a) If the class has constructor and I try to inject, no problems..it works
b) As soon as I add a string Propertty to inject some static text, I get a error thrown in the class. The property isn't doing anything in the class-not even setting a text box. As soon as I comment out the property from the XML, things work.
Any ideas? I'm using Spring.NEt 1.0.2.
Here is a sample:
I added Form1 to the project:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace MyAssembly
{
public partial class Form1 : Form
{
public string MyText
{
set
{
// do nothing.
}
}
public Form1()
{
InitializeComponent();
}
}
}
This form doesn't have any controls (just added Form1 and added the property).
I'm using:
IApplicationContext appctx= new XmlApplicationContext(
"file://views.spring.cfg.xml"
);
Form mainForm = appctx.GetObject("appShellForm");
Application.Run(mainForm);
Using XmlApplicationContext, because the error messages are more detailed than if you use ContextRegistery and app.config handlers.
The XML is (views.spring.cfg.xml):
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.net
http://www.springframework.net/xsd/spring-objects.xsd" >
<object id="appShellForm" type="MyAssembly.Form1, MyAssembly">
<!--<property name="MyText" value="Set Me" />-->
</object>
</objects>
When I uncomment the property setter, I get the following error:
Error creating object with name 'appShellForm' defined in 'file [C:\todelete\MyAssembly\bin\Debug\views.spring.cfg. xml]' : Initialization of object failed : Could not load file or assembly 'antlr.runtime, Version=2.7.5.22, Culture=neutral, PublicKeyToken=65e474d141e25e07' or one of its dependencies. The system cannot find the file specified.
This is stumping me. The only thing left, is for me to create a brand new project and start adding files one by one. I'll probably try that and see. Thanks in advance.