new exception wrong ctor called

loheronloheron Larry OHeronOrganization: LLE/UofRProject: distributed appsMember
I've attached a zip file of the vs 2005 solution. Inside is a text file with further details.

The default constructor is being called on the client side for an exception thrown from the server side with the ctor(string) method. This is in contradtion to Per 14.10 of the manual. Cited below:

The ancestor of all exceptions is System.ApplicationException.
Derived from that is Ice.Exception, which provides the definitions for a
number of constructors. Ice.LocalException and Ice.UserException
are derived from Ice.Exception and form the base for all run-time and user
exceptions.
The constructors defined in Ice.Exception have the following signatures:
public abstract class Exception : System.ApplicationException
{
public Exception();
public Exception(string msg);
public Exception(System.Exception ex);
public Exception(string msg, System.Exception ex);
}
Each concrete derived exception class implements these constructors. The
constructors initialize the Message and InnerException properties of
ApplicationException. (The default constructor initializes the Message
property to the name of the exception.)

Comments

  • michimichi Michi HenningOrganization: Triodia TechnologiesProject: I have a passing interest in Ice :-)Member ✭✭✭
    Hi Lawrence,

    I'm not sure exactly what you think is wrong here. By the sounds of things, you expect the unmarshaling code in the client to use the same constructor that was used by the server to construct the exception?

    As far as I can see, the manual doesn't say anything about which constructor will be called by the unmarshaling code--it simply states what each constructor does. The unmarshaling code may use any of these constructors to instantiate an exception before throwing it.

    The Ice run time certainly makes no promises about which constructor will be used to instantiate an exception. In fact, implementing this would be impossible without a protocol change because the information about which constructor was used by the remote end is not passed over the wire to the receiving client.

    Also, why do you care about which constructor is called? As far as I can see, it makes no difference, as long as the exception that is thrown is initialized correctly.

    Cheers,

    Michi.
  • loheronloheron Larry OHeronOrganization: LLE/UofRProject: distributed appsMember
    Message member of Ice.Exception does have marshalled string from server side.

    The problem is that on the servant side I use:
    throw new MyException("here is my string");
    which is supposed to set the message member to "here is my string".

    On the client side, the runtime uses MyException() which sets the message member to "MyException". Hence I've lost the info that I provided in the constructor on the servant side.

    P.S. I tried to attach the zip file but I got ZeroC database error three consecutive times. I will reply to your email with the zip file.

    I pasted in the more detailed explanation in the text file included in the zip file.

    ============================
    FSDControl Exception inherits from FSDException which inherits from Ice.Exception.

    In the slice generated *.cs files, (which are linked into the client and server
    projects), I set breakpoints on FSDControlException() and FSDControlException(string).
    I set breakpoints on FSDException() and FSDException(string).

    The servant throws an FSDControlException("my message") which is marshalled.
    The order in which the breakpoints were hit was:
    - FSDControlException(string).
    - FSDException(string)
    The end result is that "my message" is marshalled, presumably in the message member.

    The client catches an FSDControlException() exception.
    The order in which the breakpoints on the client were hit was:
    - FSDControlException(). // Incorrect; should be FSDControlException(string).
    // I've now lost the contents of the message member on the server side.
    - FSDException(string) // uses default value of "FSDControlException"


    Pls advise. This causes the message in FSDControlException to be lost after marshalling and before unmarshalling.

    VS2005 V8
    .net framework V2 sp1
    Ice 3.1.0

    I commented out the code that refs an external 3rd party sdk.

    Thank you,
    Lawrence O'Heron
    UofR/LLE
  • dwaynedwayne St. John's, NewfoundlandDwayne BooneOrganization: ZeroC, Inc.Project: Internet Communications EngineMember
    Hi Lawrence,

    Could you email the zip file to [email protected] rather than to Michi directly. Thanks.

    Dwayne
  • dwaynedwayne St. John's, NewfoundlandDwayne BooneOrganization: ZeroC, Inc.Project: Internet Communications EngineMember
    I should also mention that 3.1.0 is a pretty old version of Ice. Have you tried 3.3.0 to see if the problem still exists?

    Dwayne
  • loheronloheron Larry OHeronOrganization: LLE/UofRProject: distributed appsMember
    new exception on server; wrong ctor called on client

    Emailed zip file as attachment to [email protected]

    Unfortunately, an in-house developer used certain aspects of 3.1.0 (no longer supported) to develop an in-house framework. I can not upgrade because that breaks the framework that he developed.

    We are in the process of pulling out the in-house framework, but that will occur over the long run. His framework made it into several large-scale project that I have been assigned, and it must come out of all of them before I can upgrade.

    Larry O'Heron
  • dwaynedwayne St. John's, NewfoundlandDwayne BooneOrganization: ZeroC, Inc.Project: Internet Communications EngineMember
    Hi Lawrence,

    Your exception hierarchy looks like this
        exception FSDException  
        { 
             string message;
        };
    
        exception FSDControlException extends FSDException
        { 
        };
    

    I am bit confused by your description of the problem and whether you are expecting message as defined in Slice or the ApplicationException Message property to be set. I am going to assume it is the slice exception member message that you want set, and to remove any further confusion I am going to rename it so the slice is as follows:
        exception FSDException  
        { 
             string msg;
        };
    
        exception FSDControlException extends FSDException
        { 
        };
    

    Now, you are creating the exception on the server side using the following code
        throw new FSDControlException("my message string");
    

    For Ice 3.1.0 the above code does not set the exception msg data member. From Ice 3.2.0 onward the above code would be correct as we added one-shot constructors. Here is the relevant entry from our CHANGES file.
    - The exception mapping now provides "one-shot" constructors that
      permit the data members of an exception to be initialized during
      construction (similar to the way class members can be initialized
      during construction).
    
      With this new mapping, the "Message" property of the base class
      System.ApplicationException can no longer be set; the property is
      initialized to the empty string. See the Ice Manual for more
      details.
    

    Therefore with Ice 3.1.0, in order to do what I think you want to do, you need to do the following:
        FSDControlException ex = new FSDControlException();
        ex.msg = "my message string";
        throw ex;
    

    If I have misunderstood your problem and you are expecting Message property to be set, please let me know.

    Dwayne
  • loheronloheron Larry OHeronOrganization: LLE/UofRProject: distributed appsMember
    new exception wrong ctor called

    Dwayne,
    Thank you. Your analysis of my situation was correct.
    I understand your points.
    I will do as you suggest and further, I will upgrade at the earliest possible opportunity.
Sign In or Register to comment.