You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Jason Taylor <jt...@escoinst.com> on 2006/01/30 23:29:34 UTC

Error configuring DAO. Cause: Ambiguous match found.

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)




RE: Error configuring DAO. Cause: Ambiguous match found.

Posted by Jason Taylor <jt...@escoinst.com>.
Excellent, I'll look into that. 

Thanks.

Jason




-----Original Message-----
From: Aaron Hursman [mailto:AHursman@navigatorsystems.com] 
Sent: February 2, 2006 3:02 PM
To: user-cs@ibatis.apache.org; user-cs@ibatis.apache.org
Subject: RE: Error configuring DAO. Cause: Ambiguous match found.

in my enviroment (vs.net 2005, asp.net 2.0, dataaccess 1.7 beta, datamapper
1.3 beta), i was having this problem, too.  it was because: 1) the
declaration portions of some of my configuration files (dao.config,
sqlmap.config, sqlmap.xml, ...) was using the old syntax, and 2) i was using
an older version of the castle.dynamicproxy.dll.  make sure 1) the tops of
those config files match the new syntax defined in the documentation for the
beta versions of datamapper and dataaccess, and 2) you use the newest
version of castle.dynamicproxy.dll.
 

________________________________

From: Jason Taylor [mailto:jtaylor@escoinst.com]
Sent: Tue 1/31/06 03:01 PM
To: user-cs@ibatis.apache.org
Subject: RE: Error configuring DAO. Cause: Ambiguous match found.




The plot has taken a sudden turn.

It seems to depend on which version of NUnit I'm using as to whether or not
the test will fail:

Compiled in VS2005, tested using NUnit for .NET 2.0 = fail
Compiled in VS2003, tested using NUnit for .NET 2.0 = fail
Compiled in VS2003, tested using NUnit for .NET 1.1 = success !

The constant seems to be NUnit for .NET 2.0.

Has anyone else encountered trouble with NUnit for .NET 2.0?

Thanks,

Jason


-----Original Message-----
From: Chad Humphries [mailto:chad.humphries@gmail.com]
Sent: January 31, 2006 2:27 PM
To: user-cs@ibatis.apache.org; jtaylor@escoinst.com
Subject: Re: Error configuring DAO. Cause: Ambiguous match found.

Jason,

I've been using iBatis in .NET 2.0 (the 1.x build) with no issues so
far.  If you are able to replicate the issue on a smaller scale (test
project, test case) please post it to the list, I would love to look
at it and see if I can replicate it.

-Chad

On 1/31/06, Jason Taylor <jt...@escoinst.com> wrote:
> Hello everyone,
>
> I have solved my problem regarding the ambiguous match issue; in short I
was
> using VS 2005 instead of VS 2003.
>
> When I recreated my project in VS 2003 everything worked fine.
>
> I imagine this has been asked before, but what, if any, support for the
.NET
> Framework 2.0 is planned?
>
> Any insight on the particulars of this 'ambiguous match' issue would be
> welcome as well.
>
> Thanks again,
>
> Jason
>
>
>









RE: Error configuring DAO. Cause: Ambiguous match found.

Posted by Aaron Hursman <AH...@navigatorsystems.com>.
in my enviroment (vs.net 2005, asp.net 2.0, dataaccess 1.7 beta, datamapper 1.3 beta), i was having this problem, too.  it was because: 1) the declaration portions of some of my configuration files (dao.config, sqlmap.config, sqlmap.xml, ...) was using the old syntax, and 2) i was using an older version of the castle.dynamicproxy.dll.  make sure 1) the tops of those config files match the new syntax defined in the documentation for the beta versions of datamapper and dataaccess, and 2) you use the newest version of castle.dynamicproxy.dll.
 

________________________________

From: Jason Taylor [mailto:jtaylor@escoinst.com]
Sent: Tue 1/31/06 03:01 PM
To: user-cs@ibatis.apache.org
Subject: RE: Error configuring DAO. Cause: Ambiguous match found.




The plot has taken a sudden turn.

It seems to depend on which version of NUnit I'm using as to whether or not
the test will fail:

Compiled in VS2005, tested using NUnit for .NET 2.0 = fail
Compiled in VS2003, tested using NUnit for .NET 2.0 = fail
Compiled in VS2003, tested using NUnit for .NET 1.1 = success !

The constant seems to be NUnit for .NET 2.0.

Has anyone else encountered trouble with NUnit for .NET 2.0?

Thanks,

Jason


-----Original Message-----
From: Chad Humphries [mailto:chad.humphries@gmail.com]
Sent: January 31, 2006 2:27 PM
To: user-cs@ibatis.apache.org; jtaylor@escoinst.com
Subject: Re: Error configuring DAO. Cause: Ambiguous match found.

Jason,

I've been using iBatis in .NET 2.0 (the 1.x build) with no issues so
far.  If you are able to replicate the issue on a smaller scale (test
project, test case) please post it to the list, I would love to look
at it and see if I can replicate it.

-Chad

On 1/31/06, Jason Taylor <jt...@escoinst.com> wrote:
> Hello everyone,
>
> I have solved my problem regarding the ambiguous match issue; in short I
was
> using VS 2005 instead of VS 2003.
>
> When I recreated my project in VS 2003 everything worked fine.
>
> I imagine this has been asked before, but what, if any, support for the
.NET
> Framework 2.0 is planned?
>
> Any insight on the particulars of this 'ambiguous match' issue would be
> welcome as well.
>
> Thanks again,
>
> Jason
>
>
>






RE: Error configuring DAO. Cause: Ambiguous match found.

Posted by Jason Taylor <jt...@escoinst.com>.
The plot has taken a sudden turn. 

It seems to depend on which version of NUnit I'm using as to whether or not
the test will fail:

Compiled in VS2005, tested using NUnit for .NET 2.0 = fail
Compiled in VS2003, tested using NUnit for .NET 2.0 = fail
Compiled in VS2003, tested using NUnit for .NET 1.1 = success !

The constant seems to be NUnit for .NET 2.0.

Has anyone else encountered trouble with NUnit for .NET 2.0?

Thanks,

Jason


-----Original Message-----
From: Chad Humphries [mailto:chad.humphries@gmail.com] 
Sent: January 31, 2006 2:27 PM
To: user-cs@ibatis.apache.org; jtaylor@escoinst.com
Subject: Re: Error configuring DAO. Cause: Ambiguous match found.

Jason,

I've been using iBatis in .NET 2.0 (the 1.x build) with no issues so
far.  If you are able to replicate the issue on a smaller scale (test
project, test case) please post it to the list, I would love to look
at it and see if I can replicate it.

-Chad

On 1/31/06, Jason Taylor <jt...@escoinst.com> wrote:
> Hello everyone,
>
> I have solved my problem regarding the ambiguous match issue; in short I
was
> using VS 2005 instead of VS 2003.
>
> When I recreated my project in VS 2003 everything worked fine.
>
> I imagine this has been asked before, but what, if any, support for the
.NET
> Framework 2.0 is planned?
>
> Any insight on the particulars of this 'ambiguous match' issue would be
> welcome as well.
>
> Thanks again,
>
> Jason
>
>
>




Re: Error configuring DAO. Cause: Ambiguous match found.

Posted by Chad Humphries <ch...@gmail.com>.
Jason,

I've been using iBatis in .NET 2.0 (the 1.x build) with no issues so
far.  If you are able to replicate the issue on a smaller scale (test
project, test case) please post it to the list, I would love to look
at it and see if I can replicate it.

-Chad

On 1/31/06, Jason Taylor <jt...@escoinst.com> wrote:
> Hello everyone,
>
> I have solved my problem regarding the ambiguous match issue; in short I was
> using VS 2005 instead of VS 2003.
>
> When I recreated my project in VS 2003 everything worked fine.
>
> I imagine this has been asked before, but what, if any, support for the .NET
> Framework 2.0 is planned?
>
> Any insight on the particulars of this 'ambiguous match' issue would be
> welcome as well.
>
> Thanks again,
>
> Jason
>
>
>

Re: Error configuring DAO. Cause: Ambiguous match found.

Posted by Gilles Bayon <ib...@gmail.com>.
Chad Humphries have made a patch for VS 2005, I'm testing it and I will put
it in SVN.
If all is fine, the next release will have 2 distributions, one for . NET
V1.1 and one for .NET V2.0.
Expected the release next month.

Cheers
-Gilles


On 1/31/06, Jason Taylor <jt...@escoinst.com> wrote:
>
> Hello everyone,
>
> I have solved my problem regarding the ambiguous match issue; in short I
> was
> using VS 2005 instead of VS 2003.
>
> When I recreated my project in VS 2003 everything worked fine.
>
> I imagine this has been asked before, but what, if any, support for the
> .NET
> Framework 2.0 is planned?
>
> Any insight on the particulars of this 'ambiguous match' issue would be
> welcome as well.
>
> Thanks again,
>
> Jason
>
>
>

RE: Error configuring DAO. Cause: Ambiguous match found.

Posted by Jason Taylor <jt...@escoinst.com>.
Hello everyone,

I have solved my problem regarding the ambiguous match issue; in short I was
using VS 2005 instead of VS 2003.

When I recreated my project in VS 2003 everything worked fine.

I imagine this has been asked before, but what, if any, support for the .NET
Framework 2.0 is planned?

Any insight on the particulars of this 'ambiguous match' issue would be
welcome as well.

Thanks again,

Jason



RE: Error configuring DAO. Cause: Ambiguous match found.

Posted by Jason Taylor <jt...@escoinst.com>.
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:rongrabowski@yahoo.com] 
Sent: January 30, 2006 11:48 PM
To: user-cs@ibatis.apache.org
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 <jt...@escoinst.com> 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)
> 
> 
> 
> 





Re: Error configuring DAO. Cause: Ambiguous match found.

Posted by Ron Grabowski <ro...@yahoo.com>.
Can we see ICompanyDao and the method signatures from the class that
implements ICompanyDao. This looks like a DynamicProxy exception.

--- Jason Taylor <jt...@escoinst.com> 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)
> 
> 
> 
>