PDA

View Full Version : TypeLoadException when using AOP



FrostWorks
07-05-2006, 06:51 AM
I've been breaking my head over this exception and I cant seem to get rid of it:

I'm working on a webproject (.NET 2.0) and I'm trying to use Spring.AOP for sessionmanagement.
Therefore my controller uses IOC and AOP to get a reference to my servicelayer.
My web.config looks like this:

<object id="SessionController" type="MyLibrary.AOP.SessionController, MyLibrary.AOP"/>
<object id="AService" type="Spring.Aop.Framework.ProxyFactoryObject">
<property name="target">
<object id="ServiceLayer" type="MyLibrary.Service.AService, MyLibrary.Service"/>
</property>
<property name="interceptorNames">
<list>
<value>SessionController</value>
</list>
</property>
</object>

When I'm only using IoC it all works fine, but as soon as I'm using AOP I get the following exception:

Signature of the body and declaration in a method implementation do not match. Type: 'Spring.Aop.DynamicProxy.Proxy_3479cb52c4be48038ff d75527a12d14a'. Assembly: 'Spring.Aop.DynamicProxy, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.TypeLoadException: Signature of the body and declaration in a method implementation do not match. Type: 'Spring.Aop.DynamicProxy.Proxy_3479cb52c4be48038ff d75527a12d14a'. Assembly: 'Spring.Aop.DynamicProxy, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

Source Error:


Line 20: /// <returns>An object</returns>
Line 21: public override object GetObject( string id ) {
Line 22: IApplicationContext ctx = ContextRegistry.GetContext( );
Line 23: return ctx[id];
Line 24: }

Can someone help me with this?

Bruno Baia
07-07-2006, 07:42 AM
Hi,

I need some extra information,
How looks your service class "MyLibrary.Service.AService" ?
Does it inherit from a type, which class does it implement, etc...

-Bruno

FrostWorks
07-07-2006, 08:26 AM
Thnx for your reply,
My service class isn't that exciting it implements an interface and that's it.


namespace MyLibrary.Service{

public class AService : MyLibrary.Service.IAService{
// implementation goes here
}
}

Maybe the only exciting that happens inside the class is that is calls some generics. An example of a method:



public IList<MyDTO> GetSomeObjects( ) {
IDAOFactory daoFactory = (IDAOFactory)IoCFactory.Instance().GetObject("DAOFactory");//new NHibernateDALFactory( );
IMyObjectDao myObjectDao = daoFactory.GetMyObjectDao();
IList<MyDTO> dtoList = MyObjectAssembler.CreateDTOList( myObjectDao.GetAll( ) );
return dtoList;
}


I hope this will help you.

Bruno Baia
07-07-2006, 08:35 PM
Hi,

There is a known issue when using out/ref parameters, are you using it ?
Which Spring version are you using ?

How looks you advice "MyLibrary.AOP.SessionController" ?


-Bruno

FrostWorks
07-10-2006, 07:36 AM
Hi,

I'm using Spring.AOP version 2.1.0.2 (this is the dll version).

I'm not using any out/ref parameters, so that can't be the problem. My SessionController looks like this:
public class SessionController: IMethodInterceptor {
public SessionController( ) {
}

public object Invoke( IMethodInvocation invocation ) {
object returnValue = null;
try {
SessionManager.Instance.GetSession( );
SessionManager.Instance.BeginTransaction( );
try {
returnValue = invocation.Proceed( );
} catch ( Exception ex ) {
SessionManager.Instance.RollbackTransaction( );
}
SessionManager.Instance.CommitTransaction( );
} finally {
SessionManager.Instance.CloseSession( );
}
return returnValue;
}
}

I made a Proof of Concept for a similar application and it all worked fine int that POC :confused:.

FrostWorks
07-13-2006, 08:29 AM
I finally figured out what's going wrong with in my App.
When I use one-dimensional string arrays it all works fine. But when I start using two-dimensional string arrays I get the message I described before.

So when I am trying to wrap an advice around:
int GetRecordCount(string[,] searchCriteria) I get the TypeLoadException.
When I use
int GetRecordCount(string searchCriteria) it all works fine.

d33mb33
08-31-2006, 12:31 PM
Sorry to rake up this old thread but I'm having the same TypeLoadException problem with 2D arrays.

Is this a bug with Spring AOP? Is there a workaround other than changing the method NOT to return a 2D array?

Bruno Baia
08-31-2006, 03:43 PM
Hi,

I'm not able to reproduce this bug with 2D arrays.
Can you post the signature of the method that causes the error plz ?

-Bruno

bombon
01-15-2007, 09:02 PM
Hi Bruno,

I've the same problem using spring AOP 1.1.0 Preview 3 and passing parameters with 2d array's string.
My Interface is :
void GerarReprint(String[,] reprint, int idCentroImpressao)
My method implementation is :
public void GerarReprint(String[,] reprint, int idCentroImpressao)
{
...
}
The error ocurred in class :
"
public class TratamentoErro
{
private static SerializeArgumentsThrowsAdvice serializeArgumentsThrowsAdvice = new SerializeArgumentsThrowsAdvice();
public TratamentoErro()
{
}

public static object GetProxy(object objeto)
{
return TratamentoErro.GetProxy(objeto,"");
}

public static object GetProxy(object objeto,string metodos)
{
SdkRegularExpressionMethodPointcut pointCut = new SdkRegularExpressionMethodPointcut(metodos);
DefaultPointcutAdvisor defaultPointcutAdvisor =new DefaultPointcutAdvisor(pointCut,serializeArguments ThrowsAdvice);
ProxyFactory proxyFactory = new ProxyFactory(objeto);
proxyFactory.AddAdvisor(defaultPointcutAdvisor);
return proxyFactory.GetProxy();
}
}
"
in line "proxyFactory.GetProxy()"

The returned error is :

An unhandled exception of type 'System.TypeLoadException' occurred in mscorlib.dll

Additional information: Signature of the body and declaration in a method implementation do not match. Type: Spring.Aop.DynamicProxy.Proxy_459a8280bfdb4d54b008 36b62c17b4d6. Assembly: Spring.Aop.DynamicProxy, Version=0.0.0.0.

You've some idea for solve this problem ?

Thanks.

Bruno Baia
01-18-2007, 06:42 PM
Oi,



Additional information: Signature of the body and declaration in a method implementation do not match. Type: Spring.Aop.DynamicProxy.Proxy_459a8280bfdb4d54b008 36b62c17b4d6. Assembly: Spring.Aop.DynamicProxy, Version=0.0.0.0.

The assembly name tells me that you are not using 1.1 Preview 3.
Or maybe you copied the error msg before to try with 1.1 P3 ?

Bruno

bombon
01-19-2007, 05:09 PM
Bruno,

I'm using the correct version.
The error occurs inside in the class CompositionAopProxyTypeBuilder of the project of the AOP inside of the DynamicProxy folder in the line that makes the following Type call proxyType = typeBuilder.CreateType();
I searched the error and it's the class TypeBuilder does't obtain to treat a class that possesss an interface that requests an 2D's array

Thanks