|
From: Ruurd B. <SZ...@sz...> - 2005-02-04 12:26:52
|
Hi all,
let me quickly introduce myself, since I'm new to this list. I'm Ruurd
Boeke, freelance architect/developer in the Netherlands. At this moment
I'm working on a (very) large project for the government.
I've stumbled on Aspect# because of a request from my teamlead and
reading about aspect oriented programming as used in nhibernate and
blogs.
Please excuse me, if the following question is not supposed to be asked
on this mailing list. Your wiki is down ;-(
We are already in the finishing stages of our project and will start
deliviring within months. We have a server-client setup using remoting.
I was challenged to build the following simple functionality: without
changing the calls to the remote objects, implement a wait cursor while
the client is waiting for the return value.
(Keep in mind that I've just started using aspect# a few hours ago, so
if my approach is very silly, please correct me without holding back!)
I must say that I'm _very_ pleased with the ease that I could implement
aspect# on this. I've taken the following steps:
* In our framework where the remote object was activated with : object
requestedInterface = Activator.GetObject(interfaceType, url.ToString());
I changed the call to: object requestedInterface =
engine.WrapInterface(interfaceType, Activator.GetObject(interfaceType,
url.ToString()));
* The code to build the engine:
String contents = " import Socrates.Client.Framework.Interceptors " +
" " +
" aspect sample for [Socrates.Interfaces] " +
" " +
" pointcut method(* *(*))" +
" advice(CursorInterceptor)" +
" end" +
" " +
" end ";
* The 'CursorInterceptor'
[CLSCompliant(false)]
public object Invoke(IMethodInvocation invocation)
{
Cursor oudeCursor = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
object returnvalue = invocation.Proceed();
Cursor.Current = oudeCursor;
return returnvalue;
}
This actually works. I'm amazed. Wow. Because I'm forced to use the
WrapInterface method, I even get the added benefit of not having to make
my implemented methods virtual. This is _exacltly_ what I want!
However, I've stumbled upon a real problem: 'System.ArgumentException:
Cannot get TypeToken for a byref type.'
Investigation learns that this happens when wrapping an object target
(using WrapInterface) that inherits from a class which is indeed
marshalbyref. However, before encountering this problem I can happily
wrap a few other objects implementing exactly the same baseclass.
I'm not given the time to fully investigate this problem. Can someone
tell me if my approach should work and might work in time with newer
releases of aspect#?? (or should I jump out of the window, as was
suggested in your tutorial ;-))
Kind Regards,
Ruurd Boeke
ps. the exception:
1) Exception Information
*********************************************
Exception Type: System.ArgumentException
Message: Cannot get TypeToken for a byref type.
ParamName: NULL
TargetSite: System.Reflection.Emit.TypeToken GetTypeToken(System.Type)
HelpLink: NULL
Source: mscorlib
StackTrace Information
*********************************************
at System.Reflection.Emit.ModuleBuilder.GetTypeToken(Type type)
at System.Reflection.Emit.ILGenerator.Emit(OpCode opcode, Type cls)
at
Castle.DynamicProxy.Builder.CodeBuilder.SimpleAST.ConvertExpression.Emit(IEasyMember
member, ILGenerator gen)
at
Castle.DynamicProxy.Builder.CodeBuilder.SimpleAST.MethodInvocationExpression.Emit(IEasyMember
member, ILGenerator gen)
at
Castle.DynamicProxy.Builder.CodeBuilder.SimpleAST.ConvertExpression.Emit(IEasyMember
member, ILGenerator gen)
at
Castle.DynamicProxy.Builder.CodeBuilder.SimpleAST.ReturnStatement.Emit(IEasyMember
member, ILGenerator gen)
at
Castle.DynamicProxy.Builder.CodeBuilder.AbstractCodeBuilder.Generate(IEasyMember
member, ILGenerator il)
at Castle.DynamicProxy.Builder.CodeBuilder.EasyMethod.Generate()
at
Castle.DynamicProxy.Builder.CodeBuilder.AbstractEasyType.EnsureBuildersAreInAValidState()
at
Castle.DynamicProxy.Builder.CodeBuilder.AbstractEasyType.BuildType()
at
Castle.DynamicProxy.Builder.CodeBuilder.AbstractEasyType.BuildType()
at
Castle.DynamicProxy.Builder.CodeGenerators.BaseCodeGenerator.CreateType()
at
Castle.DynamicProxy.Builder.CodeGenerators.InterfaceProxyGenerator.GenerateCode(Type[]
interfaces)
at
Castle.DynamicProxy.Builder.DefaultProxyBuilder.CreateCustomInterfaceProxy(Type[]
interfaces, GeneratorContext context)
at Castle.DynamicProxy.ProxyGenerator.CreateCustomProxy(Type[]
interfaces, IInterceptor interceptor, Object target, GeneratorContext
context)
at Castle.DynamicProxy.ProxyGenerator.CreateCustomProxy(Type
theInterface, IInterceptor interceptor, Object target, GeneratorContext
context)
at AspectSharp.Core.CustomProxyGenerator.CreateProxy(Type inter,
Object target, Object[] mixins, IInterceptor interceptor) in
C:\Documents and Settings\szboekr\My Documents\Visual Studio
Projects\AspectSharp.src.2.1.0.0\src\AspectSharp\Core\DynamicProxy\CustomProxyGenerator.cs:line
51
at
AspectSharp.Core.Proxy.DefaultProxyFactory.ObtainInterfaceProxyInstance(AspectDefinition
aspect, Object target, Type inter, Object[] mixins,
IInvocationDispatcher dispatcher) in C:\Documents and
Settings\szboekr\My Documents\Visual Studio
Projects\AspectSharp.src.2.1.0.0\src\AspectSharp\Core\Proxy\DefaultProxyFactory.cs:line
133
at
AspectSharp.Core.Proxy.DefaultProxyFactory.CreateAndInstantiateInterfaceProxy(Type
inter, Object target, AspectDefinition aspect, IInvocationDispatcher
dispatcher) in C:\Documents and Settings\szboekr\My Documents\Visual
Studio
Projects\AspectSharp.src.2.1.0.0\src\AspectSharp\Core\Proxy\DefaultProxyFactory.cs:line
104
at
AspectSharp.Core.Proxy.DefaultProxyFactory.CreateInterfaceProxy(Type
inter, Object target, AspectDefinition aspect) in C:\Documents and
Settings\szboekr\My Documents\Visual Studio
Projects\AspectSharp.src.2.1.0.0\src\AspectSharp\Core\Proxy\DefaultProxyFactory.cs:line
83
at AspectSharp.AspectEngine.WrapInterface(Type inter, Object target)
in C:\Documents and Settings\szboekr\My Documents\Visual Studio
Projects\AspectSharp.src.2.1.0.0\src\AspectSharp\AspectEngine.cs:line
134
at Socrates.Client.Framework.ServerInterfaces.Get(Type
interfaceType) in
c:\socrates\code\socrates\client.framework\client.framework\communicatie\serverinterfaces.cs:line
134
--
De disclaimer van toepassing op e-mail van de Gemeente
Den Haag vindt u op Http://www.denhaag.nl/disclaimer
|