ironcladlou
03-14-2007, 02:19 AM
For some reason, Spring.Core (1.1.0P3 with .NET 2.0) can't instantiate my System.Windows.Forms.Form subclass. Every other object I've defined works perfectly. Whenever I try to instantiate the form, I receive the following nondescript error:
Error creating object with name 'MainForm' defined in 'config [objects]' : Initialization of object failed : Cannot instantiate Type [Aristocrat.UI.WinForms.BuddyForm] using ctor [Void .ctor()] : 'Exception has been thrown by the target of an invocation.'
The class itself is a simple subclass of System.Windows.Form. Here is the top of the class definition:
namespace Aristocrat.UI.WinForms {
public partial class BuddyForm : Form {
private Session session ;
public BuddyForm() {
...
Here is the program's entry point, Program.cs. The bold/red line is the line at which the exception is thrown:
namespace Aristocrat.UI.WinForms {
static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
IApplicationContext ctx = ContextRegistry.GetContext();
Form mainForm = (Form) ctx.GetObject("MainForm");
Application.Run(mainForm);
}
}
}
And finally, here is my app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
</sectionGroup>
</configSections>
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
<object id="MainForm" type="Aristocrat.UI.WinForms.BuddyForm, Aristocrat.UI.WinForms" singleton="false">
<property name="session" ref="MockSession" />
</object>
<object id="MockSession" type="Aristocrat.Core.Messaging.Impl.MockSession, Aristocrat.Core.Messaging" singleton="false"/>
<object id="AimSession" type="Aristocrat.Core.Messaging.Impl.AimSession, Aristocrat.Core.Messaging" singleton="false">
<property name="clientAuthKey" value="..." />
<property name="screenname" value="..." />
<property name="password" value="..." />
</object>
</objects>
</spring>
</configuration>
What gives? The only difference between the form class and my other classes is that the form class is defined as a partial class.
Error creating object with name 'MainForm' defined in 'config [objects]' : Initialization of object failed : Cannot instantiate Type [Aristocrat.UI.WinForms.BuddyForm] using ctor [Void .ctor()] : 'Exception has been thrown by the target of an invocation.'
The class itself is a simple subclass of System.Windows.Form. Here is the top of the class definition:
namespace Aristocrat.UI.WinForms {
public partial class BuddyForm : Form {
private Session session ;
public BuddyForm() {
...
Here is the program's entry point, Program.cs. The bold/red line is the line at which the exception is thrown:
namespace Aristocrat.UI.WinForms {
static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
IApplicationContext ctx = ContextRegistry.GetContext();
Form mainForm = (Form) ctx.GetObject("MainForm");
Application.Run(mainForm);
}
}
}
And finally, here is my app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
</sectionGroup>
</configSections>
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
<object id="MainForm" type="Aristocrat.UI.WinForms.BuddyForm, Aristocrat.UI.WinForms" singleton="false">
<property name="session" ref="MockSession" />
</object>
<object id="MockSession" type="Aristocrat.Core.Messaging.Impl.MockSession, Aristocrat.Core.Messaging" singleton="false"/>
<object id="AimSession" type="Aristocrat.Core.Messaging.Impl.AimSession, Aristocrat.Core.Messaging" singleton="false">
<property name="clientAuthKey" value="..." />
<property name="screenname" value="..." />
<property name="password" value="..." />
</object>
</objects>
</spring>
</configuration>
What gives? The only difference between the form class and my other classes is that the form class is defined as a partial class.