public BrokerException(BrokerError brokerError) : base(
     brokerError.ExceptionClass + " : " + brokerError.Message + "\n" + StackTraceDump(brokerError.StackTraceElements))
 {
     this.brokerError = brokerError;
 }
 protected void LooseMarshalBrokerError(
     OpenWireFormat wireFormat,
     BrokerError o,
     BinaryWriter dataOut)
 {
     dataOut.Write(o!=null);
     if (o!=null)
     {
         LooseMarshalString(o.ExceptionClass, dataOut);
         LooseMarshalString(o.Message, dataOut);
         if (wireFormat.StackTraceEnabled)
         {
             StackTraceElement[] stackTrace = o.StackTraceElements;
             dataOut.Write((short) stackTrace.Length);
             
             for (int i = 0; i < stackTrace.Length; i++)
             {
                 StackTraceElement element = stackTrace[i];
                 LooseMarshalString(element.ClassName, dataOut);
                 LooseMarshalString(element.MethodName, dataOut);
                 LooseMarshalString(element.FileName, dataOut);
                 dataOut.Write(element.LineNumber);
             }
             LooseMarshalBrokerError(wireFormat, o.Cause, dataOut);
         }
     }
 }
 protected void TightMarshalBrokerError2(
     OpenWireFormat wireFormat,
     BrokerError o,
     BinaryWriter dataOut,
     BooleanStream bs)
 {
     if (bs.ReadBoolean())
     {
         TightMarshalString2(o.ExceptionClass, dataOut, bs);
         TightMarshalString2(o.Message, dataOut, bs);
         if (wireFormat.StackTraceEnabled)
         {
             StackTraceElement[] stackTrace = o.StackTraceElements;
             dataOut.Write((short) stackTrace.Length);
             
             for (int i = 0; i < stackTrace.Length; i++)
             {
                 StackTraceElement element = stackTrace[i];
                 TightMarshalString2(element.ClassName, dataOut, bs);
                 TightMarshalString2(element.MethodName, dataOut, bs);
                 TightMarshalString2(element.FileName, dataOut, bs);
                 dataOut.Write(element.LineNumber);
             }
             TightMarshalBrokerError2(wireFormat, o.Cause, dataOut, bs);
         }
     }
 }
 protected virtual BrokerError LooseUnmarshalBrokerError(
     OpenWireFormat wireFormat,
     BinaryReader dataIn)
 {
     if (dataIn.ReadBoolean())
     {
         BrokerError answer = new BrokerError();
         
         answer.ExceptionClass = LooseUnmarshalString(dataIn);
         answer.Message = LooseUnmarshalString(dataIn);
         if (wireFormat.StackTraceEnabled)
         {
             short length = dataIn.ReadInt16();
             StackTraceElement[] stackTrace = new StackTraceElement[length];
             for (int i = 0; i < stackTrace.Length; i++)
             {
                 StackTraceElement element = new StackTraceElement();
                 element.ClassName = LooseUnmarshalString(dataIn);
                 element.MethodName = LooseUnmarshalString(dataIn);
                 element.FileName = LooseUnmarshalString(dataIn);
                 element.LineNumber = dataIn.ReadInt32();
                 stackTrace[i] = element;
             }
             answer.StackTraceElements = stackTrace;
             answer.Cause = LooseUnmarshalBrokerError(wireFormat, dataIn);
         }
         return answer;
     }
     else
     {
         return null;
     }
 }
 protected int TightMarshalBrokerError1(OpenWireFormat wireFormat, BrokerError o, BooleanStream bs)
 {
     if (o == null)
     {
         bs.WriteBoolean(false);
         return 0;
     }
     else
     {
         int rc = 0;
         bs.WriteBoolean(true);
         rc += TightMarshalString1(o.ExceptionClass, bs);
         rc += TightMarshalString1(o.Message, bs);
         if (wireFormat.StackTraceEnabled)
         {
             rc += 2;
             StackTraceElement[] stackTrace = o.StackTraceElements;
             for (int i = 0; i < stackTrace.Length; i++)
             {
                 StackTraceElement element = stackTrace[i];
                 rc += TightMarshalString1(element.ClassName, bs);
                 rc += TightMarshalString1(element.MethodName, bs);
                 rc += TightMarshalString1(element.FileName, bs);
                 rc += 4;
             }
             rc += TightMarshalBrokerError1(wireFormat, o.Cause, bs);
         }
         
         return rc;
     }
 }