When we tried running the Service, we hit this error : "Ambiguous Match"
I discovered that this is due to the Dynamic Proxy.DLL from Castle. Somehow, this code fails :
gen.Emit(OpCodes.Call, typeof(Monitor).GetMethod("Enter"));
So I modified the code to this call (based on some research) :
Which worked.
The reason for the error is due to Reflection's implementation difference from .NET 2.0 and .NET 4.0. .NET 4.0 requires a second parameter as opposed to the old one.
However, making it work is proven to be difficult as i don't have the signature key that is used for the Dynamic Proxy. Note that I decompiled the DLL to edit the code so I need to recompile it back. It took me few hours to get the original signature so that it would work on my project.
In-case you have the same issue, I have uploaded the source code that I modified as well as the resulting DLL so you can just re-use this without going through the nightmare I had gone thru.
Here's the link :
Here's the DLL link : https://www.dropbox.com/s/gk3zenow3ekoe0g/Castle.DynamicProxy.dll
Here's the source code link : https://www.dropbox.com/s/ndx1l55l8dk61n5/Castle.DynamicProxy.zip
Note that the source code was compiled using Visual Studio 2010. Enjoy!!
gen.Emit(OpCodes.Call, typeof(Monitor).GetMethod("Enter", new Type[] { typeof(object) }));
Hello my dear friend ,
ReplyDeletewe searched this solution for the last six months,thank you so much for sharing this :)
You require time to create that attractive and in addition real effort to make such a high-quality blog post Match Found error when using IBatis on .NET 4.0 or NHibernate on .NET 4.0. Caused by Castle's Dynamic Proxy.
ReplyDeleteHi,
ReplyDeleteI tried to use your .dll but I encountered this error instead? Can you help me with it as I am quite new with IBatis.
Cause: Value cannot be null.
Parameter name: Argument 'target' can't be null ---> System.ArgumentNullException: Value cannot be null.
Parameter name: Argument 'target' can't be null
at Castle.DynamicProxy.AssertUtil.NotNull(Object argument, String argumentName)
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)
Thank you.
Thanks it resolved my problem!!!
ReplyDeleteThank you very much for sharing, it solved the problem I have been troubled for a long time, thanks again!
ReplyDeletebitlis
ReplyDeletetunceli
ardahan
bingöl
muş
N6TP