Results 1 to 8 of 8

Thread: new exception wrong ctor called

  1. #1
    loheron is offline Registered User
    Name: Larry OHeron
    Organization: LLE/UofR
    Project: distributed apps
    Join Date
    Nov 2006
    Posts
    24

    new exception wrong ctor called

    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.)
    Last edited by loheron; 10-01-2008 at 05:20 PM. Reason: zeroc database upload error; couldn't attach zip file
    Lawrence O'Heron
    Univ of Rochester/Laboratory for Laser Energetics
    250 E. River Rd.
    Rochester NY 14612
    www.lle.rochester.edu

  2. #2
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055
    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.

  3. #3
    loheron is offline Registered User
    Name: Larry OHeron
    Organization: LLE/UofR
    Project: distributed apps
    Join Date
    Nov 2006
    Posts
    24

    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
    Lawrence O'Heron
    Univ of Rochester/Laboratory for Laser Energetics
    250 E. River Rd.
    Rochester NY 14612
    www.lle.rochester.edu

  4. #4
    dwayne's Avatar
    dwayne is offline ZeroC Staff
    Name: Dwayne Boone
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Jan 2005
    Location
    St. John's, Newfoundland
    Posts
    397
    Hi Lawrence,

    Could you email the zip file to support@zeroc.com rather than to Michi directly. Thanks.

    Dwayne

  5. #5
    dwayne's Avatar
    dwayne is offline ZeroC Staff
    Name: Dwayne Boone
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Jan 2005
    Location
    St. John's, Newfoundland
    Posts
    397
    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

  6. #6
    loheron is offline Registered User
    Name: Larry OHeron
    Organization: LLE/UofR
    Project: distributed apps
    Join Date
    Nov 2006
    Posts
    24

    new exception on server; wrong ctor called on client

    Emailed zip file as attachment to support@...

    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
    Lawrence O'Heron
    Univ of Rochester/Laboratory for Laser Energetics
    250 E. River Rd.
    Rochester NY 14612
    www.lle.rochester.edu

  7. #7
    dwayne's Avatar
    dwayne is offline ZeroC Staff
    Name: Dwayne Boone
    Organization: ZeroC, Inc.
    Project: Internet Communications Engine
    Join Date
    Jan 2005
    Location
    St. John's, Newfoundland
    Posts
    397
    Hi Lawrence,

    Your exception hierarchy looks like this

    Code:
        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:

    Code:
        exception FSDException  
        { 
             string msg;
        };
    
        exception FSDControlException extends FSDException
        { 
        };
    Now, you are creating the exception on the server side using the following code

    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.

    Code:
    - 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:

    Code:
        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

  8. #8
    loheron is offline Registered User
    Name: Larry OHeron
    Organization: LLE/UofR
    Project: distributed apps
    Join Date
    Nov 2006
    Posts
    24

    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.
    Lawrence O'Heron
    Univ of Rochester/Laboratory for Laser Energetics
    250 E. River Rd.
    Rochester NY 14612
    www.lle.rochester.edu

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 06-01-2005, 10:54 PM
  2. something wrong about cout
    By simpley in forum Help Center
    Replies: 2
    Last Post: 08-05-2004, 02:09 AM
  3. Replies: 0
    Last Post: 07-28-2004, 05:16 AM
  4. What's wrong with the example?
    By lisiliao in forum Help Center
    Replies: 2
    Last Post: 05-04-2004, 01:43 AM
  5. portability problems with RecMutex ctor
    By marlowa in forum Patches
    Replies: 6
    Last Post: 02-23-2003, 03:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •