Hi Ron,
Thanks for the reply.
Below are some more code samples from my stalled project.
If I remove ICompanyDao's 'GetByID' method, (and it's corresponding call in
the CompanyService ), leaving ICompanyDao devoid of any members, everything
seems to work!
The moment I include a method in the ICompanyDao I get the "Error
configuring DAO. Cause: Ambiguous match found" error.
Any input appreciated.
Many thanks
Jason
************************
ICompanyDao:
************************
using System;
// For CompanyVO
using Data.Domain.Source.Directory.Core;
namespace Data.Persistence.Interface.Directory.Core {
public interface ICompanyDao {
CompanyVO GetByID( string companyId );
}
}
************************
CompanyDao
************************
using System;
using System.Collections.Generic;
using IBatisNet.DataAccess.Exceptions;
// For BaseDao
using Data.Persistence.Source.Base;
// For ICompanyDao
using Data.Persistence.Interface.Directory.Core;
// For CompanyVO
using Data.Domain.Source.Directory.Core;
namespace Data.Persistence.Source.Directory.Core {
public class CompanyDao : BaseDao, ICompanyDao {
public CompanyVO GetByID( string companyId ) {
try {
return ( CompanyVO ) Mapper.QueryForObject(
"Company_GetByID", companyId );
}
catch ( DataAccessException ex ) {
throw new DataAccessException( "Error
executing CompanyDao GetByID( "
+ companyId + " ). Cause : " +
ex.Message, ex );
}
}
}
}
************************
BaseDao
************************
using System;
using IBatisNet.DataAccess;
using IBatisNet.DataAccess.DaoSessionHandlers;
using IBatisNet.DataAccess.Interfaces;
using IBatisNet.DataMapper;
namespace Data.Persistence.Source.Base {
public abstract class BaseDao : IDao {
public SqlMapper Mapper {
get {
return GetSqlMapDaoSession( ).SqlMap;
}
}
protected SqlMapDaoSession GetSqlMapDaoSession( ) {
DaoManager manager = DaoManager.GetInstance( this );
return ( SqlMapDaoSession ) manager.LocalDaoSession;
}
}
}
************************
CompanyService
************************
using System;
using Data.Service.Source.Base;
using Data.Domain.Source.Directory.Core;
using Data.Persistence.Interface.Directory.Core;
namespace Data.Service.Source.Directory.Core {
public class CompanyService : BaseService {
private static CompanyService _instance = new
CompanyService( );
private ICompanyDao _companyDao = null;
private CompanyService( ) {
_companyDao = ( ICompanyDao ) _daoManager.GetDao(
typeof( ICompanyDao ) );
}
public static CompanyService Instance( ) {
return _instance;
}
public CompanyVO GetByID( string companyId ) {
CompanyVO companyVo = null;
_daoManager.OpenConnection( );
companyVo = _companyDao.GetByID( companyId );
_daoManager.CloseConnection( );
return companyVo;
}
}
}
************************
dao.config
************************
<?xml version="1.0" encoding="utf-8"?>
<daoConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="Schema/DaoConfig.xsd">
<providers resource="Data.Service/Config/Base/providers.config" />
<context id="SqlMapperContext">
<daoSessionHandler id="SqlMap">
<property name="resource"
value="Data.Service/Config/Base/SqlMap.config" />
</daoSessionHandler>
<database>
<provider name="SqlAnywhere8.0.2" />
<dataSource
name="SqlAny8Data"
connectionString="eng=MyServer;dbn=MyDb;uid=MyUid;pwd=MyPwd;links=tcpip"
/>
</database>
<daoFactory>
<dao
interface="Data.Persistence.Interface.Directory.Core.ICompanyDao,
Data.Persistence"
implementation="Data.Persistence.Source.Directory.Core.CompanyDao,
Data.Persistence" />
</daoFactory>
</context>
</daoConfig>
************************
-----Original Message-----
From: Ron Grabowski [mailto:[EMAIL PROTECTED]
Sent: January 30, 2006 11:48 PM
To: [email protected]
Subject: Re: Error configuring DAO. Cause: Ambiguous match found.
Can we see ICompanyDao and the method signatures from the class that
implements ICompanyDao. This looks like a DynamicProxy exception.
--- Jason Taylor <[EMAIL PROTECTED]> wrote:
> Hello everyone;
>
> I'm fairly new to iBATIS and I seem to have hit a wall that I can't
> get
> around.
>
> I keep getting the error message "Error configuring DAO. Cause:
> Ambiguous
> match found", when I try to access a Dao (CompanyDao) through the
> DaoManager
> by calling the corresponding IDao (ICompanyDao).
>
> The solution is made up of 4 projects:
>
> Data.Domain ( domain/value classes, common code )
> Data.Persistence ( Daos and their corresponding interfaces )
> Data.Service ( Service classes that inherit a reference to a
> DaoManager )
> Data.Service.Test ( Unit tests for Data.Service )
>
> ********************************
> Here is a sample Service class:
> ********************************
> using System;
> using Data.Service.Source.Base;
> using Data.Domain.Source.Directory.Core;
> using Data.Persistence.Interface.Directory.Core;
>
> namespace Data.Service.Source.Directory.Core {
>
> public class CompanyService : BaseService {
>
> private static CompanyService _instance = new
> CompanyService( );
>
> private ICompanyDao _companyDao = null;
>
> private CompanyService( ) {
> _companyDao = ( ICompanyDao ) _daoManager.GetDao(
> typeof( ICompanyDao ) );
> }
>
> public static CompanyService Instance( ) {
> return _instance;
> }
>
> public CompanyVO GetByID( string companyId ) {
> CompanyVO companyVo = null;
>
> _daoManager.OpenConnection( );
> companyVo = _companyDao.GetByID( companyId );
> _daoManager.CloseConnection( );
>
> return companyVo;
> }
>
> }
> }
> ***********************************
>
>
> I have been puzzling over this for quite a while.
>
> Any hint as to what I might have done wrong would be very much
> appreciated.
>
> Thanks in advance,
>
> Jason Taylor
>
>
> P.S. I have included the Exception Message and the Stack Trace below
>
>
> MESSAGE:
>
> System.TypeInitializationException : The type initializer for
> 'Data.Service.Source.Directory.Core.CompanyService' threw an
> exception.
> ----> IBatisNet.Common.Exceptions.ConfigurationException :
> - The error occurred while add global properties.
> - configure dao
> - The error occurred in <dao
> interface="Data.Persistence.Interface.Directory.Core.ICompanyDao,
> Data.Persistence"
> implementation="Data.Persistence.Source.Directory.Core.CompanyDao,
> Data.Persistence" />.
> - Check the Data.Persistence.Source.Directory.Core.CompanyDao,
> Data.Persistence.
> ----> IBatisNet.Common.Exceptions.ConfigurationException : Error
> configuring DAO. Cause: Ambiguous match found.
> ----> System.Reflection.AmbiguousMatchException : Ambiguous match
> found.
>
>
> STACK TRACE:
>
> at Data.Service.Source.Directory.Core.CompanyService.Instance()
> at
>
Data.Service.Test.Source.Directory.Core.CompanyServiceTest.TestService()
> in
> E:\Projects\The ESCO
>
Institute\Applications\Esco.2007\Data.Service.Test\Source\Directory\Core\Com
> panyServiceTest.cs:line 13
> --TypeInitializationException
> at Data.Service.Source.Base.BaseService.setDaoManager() in
> E:\Projects\The ESCO
>
Institute\Applications\Esco.2007\Data.Service\Source\Base\BaseService.cs:lin
> e 19
> at Data.Service.Source.Base.BaseService..ctor() in E:\Projects\The
> ESCO
>
Institute\Applications\Esco.2007\Data.Service\Source\Base\BaseService.cs:lin
> e 25
> at Data.Service.Source.Directory.Core.CompanyService..ctor() in
> E:\Projects\The ESCO
>
Institute\Applications\Esco.2007\Data.Service\Source\Directory\Core\CompanyS
> ervice.cs:line 14
> at Data.Service.Source.Directory.Core.CompanyService..cctor() in
> E:\Projects\The ESCO
>
Institute\Applications\Esco.2007\Data.Service\Source\Directory\Core\CompanyS
> ervice.cs:line 10
> --ConfigurationException
> at IBatisNet.DataAccess.Configuration.Dao.Initialize(DaoManager
> daoManager)
> at
>
IBatisNet.DataAccess.Configuration.DomDaoManagerBuilder.ParseDaoFactory(Conf
> igurationScope configurationScope, DaoManager daoManager)
> at
>
IBatisNet.DataAccess.Configuration.DomDaoManagerBuilder.GetContexts(Configur
> ationScope configurationScope)
> at
>
IBatisNet.DataAccess.Configuration.DomDaoManagerBuilder.BuildDaoManagers(Xml
> Document document, Boolean useConfigFileWatcher)
> --ConfigurationException
> at System.RuntimeType.GetMethodImpl(String name, BindingFlags
> bindingAttr, Binder binder, CallingConventions callConv, Type[]
> types,
> ParameterModifier[] modifiers)
> at System.Type.GetMethod(String name)
> at
>
Castle.DynamicProxy.Builder.CodeBuilder.SimpleAST.MethodTokenExpression.Emit
> (IEasyMember member, ILGenerator gen)
> at
>
Castle.DynamicProxy.Builder.CodeBuilder.SimpleAST.MethodInvocationExpression
> .Emit(IEasyMember member, ILGenerator gen)
> at
>
Castle.DynamicProxy.Builder.CodeBuilder.SimpleAST.AssignStatement.Emit(IEasy
> Member member, ILGenerator gen)
> at
>
Castle.DynamicProxy.Builder.CodeBuilder.AbstractCodeBuilder.Generate(IEasyMe
> mber member, ILGenerator il)
> at Castle.DynamicProxy.Builder.CodeBuilder.EasyMethod.Generate()
> at
>
Castle.DynamicProxy.Builder.CodeBuilder.AbstractEasyType.EnsureBuildersAreIn
> AValidState()
> at
> Castle.DynamicProxy.Builder.CodeBuilder.AbstractEasyType.BuildType()
> at
>
Castle.DynamicProxy.Builder.CodeGenerators.BaseCodeGenerator.CreateType()
> at
>
Castle.DynamicProxy.Builder.CodeGenerators.InterfaceProxyGenerator.GenerateC
> ode(Type[] interfaces, Type targetType)
> at
>
Castle.DynamicProxy.Builder.DefaultProxyBuilder.CreateInterfaceProxy(Type[]
> interfaces, Type type)
> at Castle.DynamicProxy.ProxyGenerator.CreateProxy(Type[]
> interfaces,
> IInterceptor interceptor, Object target)
> at IBatisNet.DataAccess.Configuration.DaoProxy.NewInstance(Dao
> dao)
> at IBatisNet.DataAccess.Configuration.Dao.Initialize(DaoManager
> daoManager)
>
>
>
>