473,322 Members | 1,408 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

RealProxy used locally

Hello,

I want to be able to call methods of a type A (which implements interface
IA) on an object which is of type B (and implements interface IB). I have a
table that mapps every method of type IA to its corresponding method in type
IB.

The method that I want to call is this one:

public int a1(IA pa, int recursionNb)
{
if (recursionNb <= 0) return 1;
else return pa.a1(pa, recursionNb - 1);
}
(The method that corresponds in IB is exactly the same, but IA is replaced
by IB)

To do this I use a proxy:

public class DynamicProxy : RealProxy
{
private object targetObj = null;
private Type proxyType = null;

public DynamicProxy(Type t, object o) : base(t)
{
proxyType = t; //type IA
targetObject = o; //object of type B on which the method will be
called
}

public override IMessage Invoke(IMessage msg)
{

IMethodMessage m = (IMethodMessage)msg;

//In m, I can find the method that has been called with its
parameters (a1).
//I get the MethodInfo mi of the corresponding method (b1)
//However, I cannot call mi.Invoke(targetObject, {pa, recursionNb})
since pa is of type A.
//Thus I create a DynamicProxy:

DynamicProxy dp = new DynamicProxy(typeof(IB), pa);
object tProxy = dp.GetTransparentProxy();
object[] params = {tProxy, recursionNb};

int res = mi.Invoke(targetObject, params);

return new IMessage(res, null, 0, m.LogicalCallContext,
(IMethodCallMessage)m);
}
}

Then in the main method, I have:

DynamicProxy dProxy = new DynamicProxy(typeof(IA), objB); //objB is an
object of type B
IA transProxy = (IA)dProxy.GetTransparentProxy();
int i = transProxy.a1(new A(), 10);

There is a problem when the targetObject is a __TransparentProxy (that is
recursionNb >= 2). The problems happens when calling Invoke on the
MethodInfo, with the __TransparentProxy as a parameter.
No exception is thrown, but no method is called. Even with the debugger I
cannot step into mi.Invoke(targetObject, param), when targetObject is of
type __TransparentProxy.

I don't understand, why this is not possible.

Thanks
Valéry
Nov 15 '05 #1
0 1221

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Aardwolf | last post by:
I've had PHP on my Win2K server running IIs 5 for about 2 weeks now. I have an annoying problem in that I can not run the php scripts/pages locally, instead they open up in the browser as a...
2
by: Joel | last post by:
Hello, ASP does not work locally on my main web site when I browse the machine locally at the console itself, but to the outside world all is fine, and ASP executes normally. I have 4 other...
0
by: Shailesh | last post by:
Metalink says that, whenever we migrate from dictionary managed to locally managed tablespaces, 'Migrated tablespaces are not subject to the UNIFORM/SYSTEM policy of newly created locally managed...
3
by: Andrew Poulos | last post by:
If I do something like the following snippet in JS: xFile = "test.xml"; xDoc = document.implementation.createDocument("", "theXdoc", null); xDoc.load(xFile); // there's a pause here then ...
2
by: faktujaa | last post by:
Hi, I have created an application that uses IIS to host remote components. All the remote components are listed in app.config in client and web.config in server. Now the app.config can contain...
0
by: Valéry Bezençon | last post by:
Hello, I want to be able to call methods of a type A (which implements interface IA) on an object which is of type B (and implements interface IB). I have a table that mapps every method of type...
0
by: Hrvoje Vrbanc | last post by:
Hello all! What would be the most convenient way to deploy a locally developed ASP.NET application on a remote server that has .NET Framework (correct version) installed but I don't have any...
94
by: Samuel R. Neff | last post by:
When is it appropriate to use "volatile" keyword? The docs simply state: " The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock...
10
by: rbenditt | last post by:
I've put together a simple script that uses the XMLHttpRequest() function. It works when I run it locally, but when I upload it to my web hosting account, I never get a response back. Here is what I...
1
by: Alex | last post by:
Hello, I've written a Console application in VB 2005 which parses some files and stores the results in an MS SQL database. It runs beautifully locally, but as soon as I stick the compiled EXE...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.