473,399 Members | 3,603 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,399 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 1223

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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.