I am struggling to implement Ibatis in a windows based application. I
have followed the NPetShop tutorial as an example. I have no problem
implementing IBatis in my Java based applicaitons.
I keep recieving an error:
System.TypeInitializationException: The type initializer for
'Test.Service.RecruiterService' threw an exception. --->
System.NullReferenceException: Object reference not set to an instance
of an object.
at Test.Service.RecruiterService..ctor() in
C:\source\TEST\TEST\Test.Service\RecruiterService.cs:line 47
at Test.Service.RecruiterService..cctor() in
C:\source\TEST\TEST\Test.Service\RecruiterService.cs:line 17
--- End of inner exception stack trace ---
at Test.Service.RecruiterService.GetInstance()
at Test.Client.Form1.button1_Click(Object sender, EventArgs e) in
C:\source\TEST\TEST\Test.Client\Form1.cs:line 32
A first chance exception of type 'System.TypeInitializationException'
occurred in Test.Client.exe
The thread 'Win32 Thread' (0xadc) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x35c) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xf1c) has exited with code 0 (0x0).
The program '[2424] Test.Client.exe: Managed' has exited with code 0 (0x0).
The program '[2424] Test.Client.exe: Native' has exited with code 0 (0x0).
My guess, based on the error is something is not being initialized
properly. I have implemented a dao.config, a SqlMap.config,
providers.config and I have a Recruiter.xml.
All these files are placed into the Debug directory from which the
application executes from.
dao.config:
<?xml version="1.0" encoding="utf-8" ?>
<daoConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="DaoConfig.xsd">
<context name="SqlMapDao">
<daoSessionHandler name="SqlMap">
<property name="sqlMapConfigFile" value="sqlMap.config"/>
</daoSessionHandler>
<!-- ==== Sql Server : SqlClient configuration ========= -->
<database>
<provider name="sqlServer1.1"/>
<dataSource name="SummitExecProd" connectionString="data
source=(local)\NetSDK;database=test;user
id=sa;password=dofa7h;connection reset=false;connection lifetime=5; min
pool size=1; max pool size=50"/>
</database>
<daoFactory assembly="NPetshop.Persistence.dll">
<dao name="Recruiter"
implementation="Test.Persistence.MapperDao.Recruiter.RecruiterSqlMapDao"/>
</daoFactory>
</context>
</daoConfig>
sqlMap.config
<?xml version="1.0" encoding="utf-8"?>
<sqlMapConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="SqlMapConfig.xsd">
<settings>
<setting useStatementNamespaces="false"/>
<setting cacheModelsEnabled="true"/>
</settings>
<!-- ==== SqlClient configuration ========= -->
<!-- Optional ( default ) -->
<!-- Rem : If used with a Dao it will be ignored -->
<database>
<provider name="sqlServer1.1"/>
<dataSource name="SummitExecProd" connectionString="data
source=(local)\NetSDK;database=test;user
id=sa;password=dofa7h;connection reset=false;connection lifetime=5; min
pool size=1; max pool size=50"/>
</database>
<sqlMaps>
<sqlMap resource="Maps\Recruiter.xml"/>
</sqlMaps>
</sqlMapConfig>
I have created the Service, Persistance and Domain classes just like the
NPetshop example. In the ServiceConfig.cs , the instance.daoManager is
null. How can I tell what is causing this error. How do I enable more
verbose logging for debugging purposes.
Thanks,
Randall