|
From: <hen...@gm...> - 2005-02-04 13:52:21
|
Hi Ruurd,
The problem is a method, with a a ByRef argument, in the proxied
class. DynamicProxy invokes the
System.Reflection.Emit.ModuleBuilder.GetTypeToken method when his
attempts to build the proxy. This method throws an ArgumentException
when the type is a ByRef .
We'll try to find a solution or a work around for this problem.
On Fri, 04 Feb 2005 13:25:13 +0100, Ruurd Boeke <SZ...@sz...> wr=
ote:
> Hi all,
>=20
> 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.
>=20
> Please excuse me, if the following question is not supposed to be asked
> on this mailing list. Your wiki is down ;-(
>=20
> 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.
>=20
> (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!)
>=20
> 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 =3D Activator.GetObject(interfaceType, url.ToString())=
;
> I changed the call to: object requestedInterface =3D
> engine.WrapInterface(interfaceType, Activator.GetObject(interfaceType,
> url.ToString()));
>=20
> * The code to build the engine:
> String contents =3D " import Socrates.Client.Framework.Interceptors " +
> " " +
> " aspect sample for [Socrates.Interfaces] " +
> " " +
> " pointcut method(* *(*))" +
> " advice(CursorInterceptor)" +
> " end" +
> " " +
> " end ";
>=20
> * The 'CursorInterceptor'
> [CLSCompliant(false)]
> public object Invoke(IMethodInvocation invocation)
> {
> Cursor oudeCursor =3D Cursor.Current;
> Cursor.Current =3D Cursors.WaitCursor;
> object returnvalue =3D invocation.Proceed();
> Cursor.Current =3D oudeCursor;
>=20
> return returnvalue;
> }
>=20
> 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!
>=20
> 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.
>=20
> 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 ;-))
>=20
> Kind Regards,
> Ruurd Boeke
>=20
> 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
>=20
> 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.MethodInvocationExpress=
ion.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(IE=
asyMember
> member, ILGenerator gen)
> at
> Castle.DynamicProxy.Builder.CodeBuilder.AbstractCodeBuilder.Generate(IEas=
yMember
> member, ILGenerator il)
> at Castle.DynamicProxy.Builder.CodeBuilder.EasyMethod.Generate()
> at
> Castle.DynamicProxy.Builder.CodeBuilder.AbstractEasyType.EnsureBuildersAr=
eInAValidState()
> 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.Genera=
teCode(Type[]
> interfaces)
> at
> Castle.DynamicProxy.Builder.DefaultProxyBuilder.CreateCustomInterfaceProx=
y(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\Custom=
ProxyGenerator.cs:line
> 51
> at
> AspectSharp.Core.Proxy.DefaultProxyFactory.ObtainInterfaceProxyInstance(A=
spectDefinition
> 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\DefaultProxyF=
actory.cs:line
> 133
> at
> AspectSharp.Core.Proxy.DefaultProxyFactory.CreateAndInstantiateInterfaceP=
roxy(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\DefaultProxyF=
actory.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\DefaultProxyF=
actory.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
>=20
> --
> De disclaimer van toepassing op e-mail van de Gemeente
> Den Haag vindt u op Http://www.denhaag.nl/disclaimer
>=20
> -------------------------------------------------------
> This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
> Tool for open source databases. Create drag-&-drop reports. Save time
> by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
> Download a FREE copy at http://www.intelliview.com/go/osdn_nl
> _______________________________________________
> Aspectsharp-users mailing list
> Asp...@li...
> https://lists.sourceforge.net/lists/listinfo/aspectsharp-users
>=20
--=20
Cheers,
Henry Concei=E7=E3o
|