private static void ProcessException(Exception ex)
        {
            try
            {
                CatchMe me = null;
#if !WindowsCE
                (me = CatchMe.WriteException(ex).Level(1).Screen().Where().To <LogFile>()).Write();
#else
                (me = CatchMe.WriteException(ex).Level(1).Screen().Where("UnhandledExceptionHandler").To <LogFile>()).Write();
#endif

                if (_bind != null)
                {
                    _bind(me);
                }
            }
            catch (Exception ex2)
            {
#if !WindowsCE
                new LogFile().Write((CatchMe.WriteException(ex2).Level(1).Screen().Where()));
#else
                new LogFile().Write((CatchMe.WriteException(ex2).Level(1).Screen().Where("Double UnhandledExceptionHandler")));
#endif
            }
            finally
            {
                if (!IsBatch)
                {
                    ExceptionDialog d = new ExceptionDialog();
                    d.ShowDialog();
                }
                System.Diagnostics.Process.GetCurrentProcess().Kill();
            }
        }
Пример #2
0
 public void OnAsyncWifiLog(IAsyncResult result)
 {
     try
     {
         _fs.EndWriteInJournal(result);
     }
     catch (Exception ex)
     {
         CatchMe.WriteException(ex).Where("cWifi::OnAsyncWifiLog").WriteOnly <LogFile>();
     }
 }
Пример #3
0
        public void Write(ICatchMe Entry)
        {
            if (IpAddress != null)
            {
                return;
            }

            if (Entry.UrgenceLevel.HasValue && (Level != 0))
            {
                if (Entry.UrgenceLevel.Value > Level)
                {
                    return;
                }
            }

            try
            {
#if !NET35
                if (_fs == null)
                {
                    _fs = new CatchException.Service.CatchException();
                }
                _fs.WriteInJournal(Entry.ComputerName, Entry.GetApplicationId(), true, Entry.ToHtml());
#else
#if !WindowsCE
                if (_fs == null)
                {
                    _fs = new CatchException.Service.CatchExceptionClient(new BasicHttpBinding(), new EndpointAddress(FullUrl));
                }
                _fs.WriteInJournal(Entry.ComputerName, Entry.GetApplicationId(), Entry.ToHtml());

                _fs.Close();
#else
                if (_fs == null)
                {
                    _fs = new WcfException.CatchException();
                }

                AsyncCallback cb = new AsyncCallback(OnAsyncWifiLog);
                _fs.BeginWriteInJournal(Entry.ComputerName, Entry.GetApplicationId(), true, Entry.ToHtml(), cb, null);
#endif
#endif
            }
            catch (Exception ex)
            {
                CatchMe.WriteException(ex).Where("LogWcf::Write").WriteOnly <LogFile>();
            }
        }
Пример #4
0
        string Dump(FieldInfo[] Fields, object Obj, int Level)
        {
            string ret = string.Empty;

#if NET20
            if (Fields.Length > 0)
#else
            if (Fields.Count() > 0)
#endif
            {
                foreach (var field in Fields)
                {
                    var Objval = field.GetValue(Obj);

                    Type type = Objval.GetType();

                    if (type == Obj.GetType())
                    {
                        continue;
                    }


                    string Value = null;

                    if (Objval == null)
                    {
                        Value = "Null";
                    }
                    else
                    if (type.IsPrimitive || type.Equals(typeof(string)))
                    {
                        Value = Objval.ToString();
                    }
                    else
                    if (type.IsArray)
                    {
                        Value = DumpArray(Objval, Level + 1);
                    }
                    else
                    {
                        Value = Dump(Objval, Level + 1);
                    }

                    ret += Write(string.Format("[{0}] {1} : {2} \r\n", CatchMe.GetTypeName(field.FieldType), field.Name, Value), Level);
                }
            }
            return(ret);
        }
        public static void CatchUnhandled()
        {
#if !WindowsCE
            System.Windows.Forms.Application.ThreadException -= ThreadExceptionHandler;
            System.Windows.Forms.Application.ThreadException += ThreadExceptionHandler;
            try
            {
                System.Windows.Forms.Application.SetUnhandledExceptionMode(System.Windows.Forms.UnhandledExceptionMode.CatchException);
            }
            catch (Exception ex)
            {
                new LogFile().Write((CatchMe.WriteException(ex).Level(1).Screen().Where()));
                throw new Exception("Manque la Declaration SecurityPermission");
            }
#endif

            System.AppDomain.CurrentDomain.UnhandledException -= UnhandledExceptionHandler;
            System.AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
        }
Пример #6
0
        /*
         * static string Dump(MemberInfo[] Members, object Obj, int Level)
         * {
         *   string ret = string.Empty;
         *   if (Members.Count() > 0)
         *   {
         *       foreach (var Member in Members)
         *       {
         *           object val = null; // Member.GetValue(Obj);
         *
         *           if (val == null)
         *           {
         *               string ligne = string.Format("[{0}] {1} : {2}", CatchMe.GetTypeName(Member.DeclaringType), Member.Name, "Null");
         *               ret += ligne;
         *               continue;
         *           }
         *           if (Member.MemberType.GetType().IsPrimitive || Member.MemberType.Equals(typeof(string)))
         *           {
         *               string ligne = string.Format("[{0}] {1} : {2}", CatchMe.GetTypeName(Member.DeclaringType), Member.Name, val.ToString());
         *               ret += ligne;
         *           }
         *           else
         *           {
         *
         *               string ligne = string.Format("[{0}] {1} : {2}", CatchMe.GetTypeName(Member.DeclaringType), Member.Name, Dump(val, Level + 1));
         *               ret += ligne;
         *           }
         *       }
         *   }
         *   return ret;
         * }
         */
        string Dump(PropertyInfo[] Properties, object Obj, int Level)
        {
            string ret = string.Empty;

#if NET20
            if (Properties.Length > 0)
#else
            if (Properties.Count() > 0)
#endif
            {
                foreach (var Property in Properties)
                {
                    string Value = null;
#if NET35r
                    if (!Property.GetMethod.Attributes.HasFlag(MethodAttributes.Static))
#else
                    if (!((Property.GetGetMethod().Attributes & MethodAttributes.Static) == MethodAttributes.Static))
#endif
                    {
                        if (Property.PropertyType.Equals(typeof(BindingManagerBase))
                            //  || Property.PropertyType.Equals(typeof(System.Windows.Forms.Control.ControlCollection))
                            || Property.PropertyType.Equals(typeof(AccessibleRole)) ||
                            Property.PropertyType.Equals(typeof(ControlBindingsCollection)) ||
                            Property.PropertyType.Equals(typeof(Control)) ||
                            Property.PropertyType.Equals(typeof(MethodBase))
                            )
                        {
                            continue;
                        }



                        if (Property.PropertyType.IsArray)
                        {
                            object ObjVal = Property.GetValue(Obj, null);
                            Value = DumpArray(ObjVal, Level + 1);
                        }
                        else
                        if (Property.Name == "Item")
                        {
                            PropertyInfo count = null;
#if NET35
                            count = Obj.GetType()
                                    .GetProperties()
                                    .SingleOrDefault(prop => prop.Name == "Count");
#else
                            foreach (var prop in Obj.GetType().GetProperties())
                            {
                                if (prop.Name == "Count")
                                {
                                    count = prop;
                                    break;
                                }
                            }
#endif

                            string small = string.Empty;
                            small += "{";

                            if (count != null)
                            {
                                for (int i = 0; i < (int)(count.GetValue(Obj, null)); i++)
                                {
                                    object ObjVal = Property.GetValue(Obj, new object[] { i });
                                    if (i > 0)
                                    {
                                        small += ",";
                                    }

                                    if (Property.PropertyType.IsPrimitive || Property.PropertyType.Equals(typeof(string)))
                                    {
                                        small += ObjVal.ToString();
                                    }
                                    else
                                    {
                                        small += Dump(ObjVal, Level + 1);
                                    }
                                }
                            }
                            small += "}";
                            Value  = small;
                        }
                        else
                        {
                            object ObjVal = Property.GetValue(Obj, null);

                            if (ObjVal == null)
                            {
                                Value = "Null";
                            }
                            else
                            if (Property.PropertyType.IsPrimitive || Property.PropertyType.Equals(typeof(string)))
                            {
                                Value = ObjVal.ToString();
                            }
                            else
                            {
                                Value = Dump(ObjVal, Level + 1);
                            }
                        }

                        ret += Write(string.Format("[{0}] {1} : {2} \r\n", CatchMe.GetTypeName(Property.PropertyType), Property.Name, Value), Level);
                    }
                }
            }
            return(ret);
        }