This forum has been archived. Please start a new discussion on GitHub.

Fixed Proxy & ToString

It's convenient in .NET programming sometimes to utilize the ToString function available from the base object type. I've noticed that Ice compiled .NET libraries utilize the ToString() function to print out detailed information for Proxies. This is convenient for printing / logging messages about proxies because all of the connection details are present in the resulting string.

However, Fixed Proxies (really FixedReferences) throw a FixedProxyException when invoking the ToString() function call.

So I cannot rely on the ToString function call for all proxies because of the possibility of throwing this fatal exception, and I cannot find an equivalent ICE provided function to safely obtain a string with the full proxy information for logging / printing purposes.

I've substituted the ice_getIdentity() function and am able to obtain that string, but it doesn't contain the full picture of the proxy so I'm not able to get detailed information on the objects location from the identity.

I guess I could construction a function that takes an Ice.ObjectPrx and construct a string myself using the identity and the endpoints, but any other suggestions?

Thank you


  • mes
    mes California
    Hi Rick,

    Fixed proxies are a special case because they're permanently bound to a particular connection. This is why the code doesn't allow you to marshal or stringify them.

    However, I agree that having to catch an exception is inconvenient. We'll consider adding a method in the next release so that you can at least test the proxy.

    Meanwhile, your idea of using a helper function for converting proxies to strings is probably your best bet. Also note that it is possible to obtain the Connection object from a fixed proxy by calling ice_getConnection, so you could cobble together a more meaningful description of a fixed proxy by combining its stringified identity with the output of Connection.ToString().

  • Mark, thanks for the quick response. Working around the issue is not a problem, however I just wanted to mention that I think it seems to me to be bad practice to be throwing out of the ToString() function.

    I understand that a FixedProxy is a special case, but calling ToString doesn't actually build a copy of it, or attempt to invoke an object function call on a copy of one. ToString just builds a string that contains the data from the proxy. It doesn't actually build a proxy...

    Similarly, I'm finding that the Ice.Connection.ToString is also throwing an exception if I attempt to call ToString on a connection for a local proxy, but it doesn't throw when invoked on a remote proxy.

    I just find ToString raising critical exceptions to be somewhat strange given the spirit of the function from my experience is to just take an object and "stringify" it, even if that means just returning the name of the object type.

    Regardless, I appreciate your quick help.

  • For other readers information, the function Ice.Connection.ice_toString_() appears to return valid information for the connection without throwing the Colocated Proxy exception.