CAO destructor ?

dotnet framework

    Sponsored Links


  • 1. pause remoting
    Is there a way to pause remoting for a few seconds. Maybe with unregister and then register channel. Does it works? I have windows service as a remoting server and many clients. The server occansionally runs out of memory because of pinned objects caused by remoting. One solution is to stop communication for a while and let the gc clean memory. Currently I could do that with disabling network card, but that affects all other services on the computer. Could I somehow stop receiving remoting communication for a while? Thanks, Igor.
  • 2. SoapSuds and Typed DataSets
    I have a library wich only contains typed datasets. When I run soapsuds soapsuds -ia:myTypedDataSets -gc -nowp or soapsuds -ia:myTypedDataSets -oa:TheNewAssembly.dll or any other parameters it always gives me de same error. Error:Datos del esquema no validos.. Mensaje Wsdl/portType/enlace no valido. falta la secion de entrada o salida o el nombre de la operacion de enlace de portType no corresponde : EndInvoke Anyone can help me ?? Thanks.
  • 3. Cannot receive data across socket connection by .NET app
    I have a .NET app that connects to a third-party server on a socket and sends data. This works with a test server on the local network, but does not work across the frame connection to the third-party server. They see a connection, but never see any data coming across. This works with Win32 app using winsock. However, if I use [DllImport] and call a Win32 dll that uses Winsock from my .NET app, it does not work. Is there some setting in .NET framework security or my code that I am missing? Any ideas? Thanks Subu Anantharam

CAO destructor ?

Postby Josh » Thu, 10 Mar 2005 06:19:28 GMT


I know how to use sponsors to control the lifetime of my CAOs, however, I 
have this situation where I need to write some cleanup code when my client 
disconnects.  So, is there an event to detect when the lease doesn't get 
renewed ?  Or in other words, how to implement the destructor for my CAOs ?

thx in advance 

Re: CAO destructor ?

Postby Josh » Thu, 10 Mar 2005 10:58:07 GMT

never mind, found it... if anyone else is looking for this, here's what you 
need to get IDisposable to work on your CAOs :

public class TrackingHandler : ITrackingHandler


public void MarshaledObject(Object obj, ObjRef or)



public void UnmarshaledObject(Object obj, ObjRef or)



// Notifies a handler that an object has been disconnected.

public void DisconnectedObject(Object obj)


Console.WriteLine("Tracking: An instance of {0} was disconnected. The 
instance HashCode is: {1}", obj.ToString(), obj.GetHashCode().ToString());

IDisposable dispobj = obj as IDisposable;

if (dispobj != null)






then in your server startup routine :

TrackingServices.RegisterTrackingHandler(new TrackingHandler());

"Josh" < XXXX@XXXXX.COM > schreef in bericht 

Similar Threads:

1.How to access a CAO serverside, or - how to achieve CAO functionalities with a Singleton


I'm trying to design a remoting architecture with the following requirements :
*** An object for each client instance ; that is, not only having ClientA and ClientB point to different objects, but also, for a given client, having 2 different ObjectA_1 and ObjectA_2 to proxy to a different server MBR. I know the first part is feasible with CAO, I don't know for the second one.

*** My server-side code is going to look like :
void DoSomething(string myArgs)
	// Fire an Event
because I don't know what the implementation will be like : the user will do it himself.
He therefore needs to be able to add an event handler to the server object (the event handler is exclusively server-side I repeat - the client-side Dll uses an eventless interface).

- I tried to do this with CAO, but the 2nd clause was the problem : how can I add an event handler to a CAO when I don't know where the CAO is located server-side ? I tried to seek a way of getting a signal that a client had just created a proxy, but alas so far I had no such luck.
- I then tried to do it with a Singleton, but the 1st clause was the problem : how can I keep a separate state for each client with that ? I thought of using a Hashtable where the key would be the client Ip (I'd have to create a custom server sink), but that wouldn't work with the requirement of having multiple client objects point to multiple server objects. Besides, how would I go on to maintain the object changes in the Hashtable - that is, what would be the *value* in the Hash ?

At the moment I'm completely stuck on the CAO approach, can't figure out a way to do something that doesn't seem heavy as hell with the Singleton approach - in short I'm about to stop MBR and go brute force with MBV ... I'd hate to have to that, so if anyone can give some light on this problem, I'd appreciate it *a lot*.
Thanks in advance !

2.Remote CAO Error


I'm having a problem with a remoting CAO. The CAO creates an instance of a
VB6.0 ActiveX.exe which talks to an old application though DDE. Everything
works fine when the client is a Winforms or console app. Then I try to make
an ASP.NET web page the client it fails. At first It would not create the
instance because of security, but I added the ASPNET to the Admin of the
machine and added full trust to the assembly, now it creates it. I also have
the AspCompat="true" in the page header. The error I get from the
ActiveX.exe is "foriegn app failed to respond to DDE Initiate." It appears
that the ASPnet workerprocess is not allowing the DDE conversation. I also
notice that when I shut down VisualStudio, the worker thread is still
running along with the ActiveX.exe. When I run it from one of the other
clients everything shuts down when the client closes.

I am using VS.NET 2002 Frame 1.0

Any Idea's??



3.difficult CAO remoting problem with NAT router

please don't answer this without reading the entire message.  I'm not
asking about machinename.

I am trying to figure out a way to have my remoting system deal with
being behind a firewall, a NAT router or other various network

the problem is that when using a CAO will force the server to send
back the 'address' to the client.  Because the people using this
particular product may not be very computer savvy,, I can't rely on
them entering an external IP (for that matter they may be behind a
dynamic IP so they would have to enter it every time which is

what I need to know, is how exactly do I intercept where the server is
sending back the 'unique address' to the client so I can put the IP
that the CLIENT sees the server as, not what the SERVER sees itself

machinename isn't a workable solution as most NAT routers available
these days won't re-route the IP from internal back to internal if the
external address is machinenamed in.  Also, machinename isn't workable
for the entry reasons stated above.  I need to intercept the call and
change the address sent back to the client on the fly.

4.Creating a CAO with Multiple Network Interfaces / Subnets

I have an application (C#, but I don't think that matters) using the
in which I'm using Activator.CreateInstance (Type, Object[], Object[])
to create a Client Activated Object. It works perfectly when the
client and server are both on machines with only one network interface
enabled and on the same subnet, but I'm working on an upgrade which
will require the client to have two active NICs, and be able to fetch
the remote object from a server on either NIC (or both).  I thought
since the third argument to CreateInstance is the URL of the remote
object server, it would be able to determine the appropriate network
interface to use, but the method call throws a
TargetInvocationException after a significant delay (a network error
timeout).  I'm running a packet sniffer called EtherPeek, and I can
see that no network traffic is going out on either NIC when the remote
object request is made, so it looks like the framework is just plain
confused, and can't determine which NIC on which to send the request.
(I would expect to at least see the request go out over the network,
and then have a timeout occur when no response was fired back.)

The server publishes the object using SOAP on an HttpChannel,
"useIpAddress" is set to false, and the "machineName" is set to the
Server's IP address.  (I had found many suggestions about doing this
to create a CAO through a router to a different subnet - a slightly
different situation than what's going on here.)  I can connect to both
networks with no problems, so networking is properly configured. I can
even use my web browser to see the URI, so it is properly published on
the Server.

The opposite setup (one server publishing a remote object on multiple
NICs) is easy and works fine, but I can't get this setup to work at
all. Has anyone ever seen a situation like this before, and if so,
figured out how to convince .NET to send the request out the right

Thanks much,

5.Creating a CAO instance in the same application where it is hosted


I have a CAO component which is hosted by my server. This server also 
contains function, in which i need to create an instance of this CAO. 
(This CAO object has to be passed to another process)

When I first tried to create CAO component using overloaded 
Activator.CreateInstance() method with activationAttributes that has URL 
properties, I got the following exception:

"Invalid Internal State: MarshalByRefObject should not have proxy object in 
the same AppDomain"

To overcome this, I created a new AppDomain and used CreateInstance function 
of AppDomain to create an instance of the CAO.

This function returns an reference of type ObjectHandle. When I try to 
typecast it to the CAO component type i am getting "InvalidCastException".

If I use, ObjHandle.UnWrap() the instance is no longer behaving like a 
proxy. It is a local component and i cannot pass it to another process.

Even if i send ObjHandle to another process, once it unwraps objHandle it 
becomes a local instance which it cannot use.

Is there any other way i can over come this.

Any Suggestion or input on this will help me a lot


6. CAO and scalability

7. CAO 3 tier model

8. CAO hangs after sending event to client

Return to dotnet framework


Who is online

Users browsing this forum: No registered users and 13 guest