
Originally Posted by
Mark Pollack
Hi Mark,
I'm testing spring. Net addin for Microsoft Word. The IOC control works well, But when I want to integrate NHibernate starts giving me problems.
I made a test:
context.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">
<object id="Calle" type="NotinDatos.CalleImp, NotinDatos" >
<property name="Nombre" value="prueba"/>
</object>
</objects>
I do not write anything in app.config and the code of the addin I do the following:
Code:
AplicationContext Dim As IApplicationContext = Nothing
If aplicationContext Is Nothing Then
Try
aplicationContext = New XmlApplicationContext ("file: / / ... \ context.xml")
Dim a As CalleImp = aplicationContext.GetObject ("Calle", GetType (CalleImp))
Catch ex As Exception
End Try
End If
This code works well, now I show the case where failure
context.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
xmlns:db="http://www.springframework.net/database">
<db:provider id ="DbProvider" provider ="SqlServer-2.0" connectionString ="Data Source=serv2003;Initial Catalog=Datos;Trusted_Connection=Yes;" />
<object id="sessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate12">
<property name="DbProvider" ref="DbProvider"/>
<property name="MappingAssemblies">
<list>
<value>NotinDatos</value>
</list>
</property>
<property name="HibernateProperties">
<dictionary>
<entry key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"/>
<entry key="hibernate.dialect"
value="NHibernate.Dialect.MsSql2000Dialect"/>
<entry key="hibernate.connection.driver_class"
value="NHibernate.Driver.SqlClientDriver"/>
<entry key="hibernate.show_sql"
value ="true"/>
</dictionary>
</property>
</object>
<object id="Calle" type="NotinDatos.CalleImp, NotinDatos" >
<property name="Nombre" value="prueba"/>
</object>
</objects>
In the app.config I put:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core"/>
</sectionGroup>
...
</configSections>
...
<spring>
<parsers>
<parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data" />
</parsers>
</spring >
</configuration>
I give a security issue.
This is the trace of the error:
Se produjo una excepción en el inicializador de tipo de 'Spring.Util.ObjectUtils'.
Code:
en Spring.Util.ObjectUtils.InstantiateType(Type type) en Spring.Objects.Factory.Xml.NamespaceParserRegistry.RegisterParser(Type parserType, String namespaceUri, String schemaLocation) en
Spring.Context.Support.NamespaceParsersSectionHandler.Create(Object parent, Object configContext, XmlNode section) en
System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionImpl(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader) en
System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader) en
System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSection(Boolean inputIsTrusted, RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader) en
System.Configuration.RuntimeConfigurationRecord.CreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader) en
System.Configuration.BaseConfigurationRecord.CallCreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader, String filename, Int32 line)
Spring .net version 1.3.0.20349