mcantrell
02-12-2007, 10:55 PM
Please forgive me if I've overlooked something simple, I'm new to .NET and I'm following along from the example application from the NHibernate module. I've added references to all of the DLLs in its bin/2.0 dir (I wasn't exactly sure what all of the runtime dependencies were).
When I try to run my unit test, I get the following runtime error:
Class Initialization method SpringLunchAndLearnTest.HibernateInventoryDaoTest. MyClassInitialize threw exception. System.Configuration.ConfigurationErrorsException: System.Configuration.ConfigurationErrorsException: Error instantiating context 'spring.root'. ---> Spring.Objects.FatalObjectException: Cannot instantiate Type [Spring.Context.Support.XmlApplicationContext] using ctor [Void .ctor(System.String, Boolean, System.String[])] : 'Exception has been thrown by the target of an invocation.' ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Spring.Objects.Factory.ObjectDefinitionStoreExcept ion: Error registering object with name 'DbProvider' defined in 'file [C:\dev\workspace\vs\solutions\LunchAndLearn\trunk\ SpringLunchAndLearn\TestResults\MCantrell_LI-HC96K71 2007-02-12 15_40_16\Out\Dao.xml]' : Object class [Spring.Data.Support.SqlProvider, Spring.Data] not found.
<object id="DbProvider" type="Spring.Data.Support.SqlProvider, Spring.Data" xmlns="http://www.springframework.net"><property name="ConnectionString" value="${db.connectionString}" /></object> ---> System.TypeLoadException: Could not load type from string value 'Spring.Data.Support.SqlProvider, Spring.Data'. ---> System.TypeLoadException: Could not load type 'Spring.Data.Support.SqlProvider' from assembly 'Spring.Data, Version=1.1.0.2, Culture=neutral, PublicKeyToken=null'..
Keep in mind that all of my configuration code was pretty much cut and pasted from the Northwind example included with the NHibernate Spring module. I'm at a loss to explain the missing class from the assembly. Am I missing something?
Here's a peak at some of my code. Please let me know if you need me to post anything else.
InventoryDao.cs
using Spring.Data.NHibernate.Support;
namespace SpringLunchAndLearn
{
public interface IInventoryDao
{
Inventory getById(int inventoryId);
}
public class HibernateInventoryDao : HibernateDaoSupport, IInventoryDao
{
public Inventory getById(int inventoryId)
{
return (Inventory) HibernateTemplate.Load(typeof (Inventory), inventoryId);
}
}
}
Dao.xml
<object id="DbProvider" type="Spring.Data.Support.SqlProvider, Spring.Data">
<property name="ConnectionString" value="${db.connectionString}"/>
</object>
app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="databaseSettings" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="parsers" type="Spring.Context.Support.ConfigParsersSectionHandler , Spring.Core" />
</sectionGroup>
</configSections>
<databaseSettings>
<add key="db.connectionString" value="Server=DBRPTSTG01;initial catalog=db_partnernet_2;Integrated Security=SSPI" />
</databaseSettings>
<spring>
<context>
<resource uri="Dao.xml"/>
</context>
<parsers>
<parser namespace="http://www.springframework.net/database"
type="Spring.Data.DatabaseConfigParser, Spring.Data"
schemaLocation="assembly://Spring.Data/Spring.Data/spring-database.xsd" />
</parsers>
</spring>
</configuration>
When I try to run my unit test, I get the following runtime error:
Class Initialization method SpringLunchAndLearnTest.HibernateInventoryDaoTest. MyClassInitialize threw exception. System.Configuration.ConfigurationErrorsException: System.Configuration.ConfigurationErrorsException: Error instantiating context 'spring.root'. ---> Spring.Objects.FatalObjectException: Cannot instantiate Type [Spring.Context.Support.XmlApplicationContext] using ctor [Void .ctor(System.String, Boolean, System.String[])] : 'Exception has been thrown by the target of an invocation.' ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Spring.Objects.Factory.ObjectDefinitionStoreExcept ion: Error registering object with name 'DbProvider' defined in 'file [C:\dev\workspace\vs\solutions\LunchAndLearn\trunk\ SpringLunchAndLearn\TestResults\MCantrell_LI-HC96K71 2007-02-12 15_40_16\Out\Dao.xml]' : Object class [Spring.Data.Support.SqlProvider, Spring.Data] not found.
<object id="DbProvider" type="Spring.Data.Support.SqlProvider, Spring.Data" xmlns="http://www.springframework.net"><property name="ConnectionString" value="${db.connectionString}" /></object> ---> System.TypeLoadException: Could not load type from string value 'Spring.Data.Support.SqlProvider, Spring.Data'. ---> System.TypeLoadException: Could not load type 'Spring.Data.Support.SqlProvider' from assembly 'Spring.Data, Version=1.1.0.2, Culture=neutral, PublicKeyToken=null'..
Keep in mind that all of my configuration code was pretty much cut and pasted from the Northwind example included with the NHibernate Spring module. I'm at a loss to explain the missing class from the assembly. Am I missing something?
Here's a peak at some of my code. Please let me know if you need me to post anything else.
InventoryDao.cs
using Spring.Data.NHibernate.Support;
namespace SpringLunchAndLearn
{
public interface IInventoryDao
{
Inventory getById(int inventoryId);
}
public class HibernateInventoryDao : HibernateDaoSupport, IInventoryDao
{
public Inventory getById(int inventoryId)
{
return (Inventory) HibernateTemplate.Load(typeof (Inventory), inventoryId);
}
}
}
Dao.xml
<object id="DbProvider" type="Spring.Data.Support.SqlProvider, Spring.Data">
<property name="ConnectionString" value="${db.connectionString}"/>
</object>
app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="databaseSettings" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="parsers" type="Spring.Context.Support.ConfigParsersSectionHandler , Spring.Core" />
</sectionGroup>
</configSections>
<databaseSettings>
<add key="db.connectionString" value="Server=DBRPTSTG01;initial catalog=db_partnernet_2;Integrated Security=SSPI" />
</databaseSettings>
<spring>
<context>
<resource uri="Dao.xml"/>
</context>
<parsers>
<parser namespace="http://www.springframework.net/database"
type="Spring.Data.DatabaseConfigParser, Spring.Data"
schemaLocation="assembly://Spring.Data/Spring.Data/spring-database.xsd" />
</parsers>
</spring>
</configuration>