Programming Languages Hacks

Importanti regole per linguaggi di programmazione rilevanti come Java, C, C++, C#…

  • Subscribe

  • Lettori

    I miei lettori abituali

  • Twitter

Crash Reporting in .NET

Posted by Ricibald on 6th August 2013

In your .NET windows application you can’t catch all exceptions. There are critical exceptions that leaves your application inconsistent: in this case let your app crash.

But wait… and error reports? You have two alternatives:

  • use the native Microsoft solution: Windows Error Reporting (WER). It’s not easy to customize but it’s fully integrated in Win OS (i.e. when your application freezes). Here how to use WER.
  • use an off-the-shelf crash reporting library:

Note: if your application is an ASP.NET application, just use the excellent ELMAH

Posted in .net | No Comments »

How to Maximize Wpf Window only vertically or horizontally

Posted by Ricibald on 5th November 2009

To maximize Wpf Window only vertically or horizontally simply use this snippet code:

    public partial class MyWindow : Window
        public MyWindow()
        private void fillHeight()
            PropertyChangedCallback tmpChanged =
                (source, args) =>
                        var workArea = (Rect)args.NewValue;
                        this.Height = workArea.Height;
            DependencyProperty tmp = DependencyProperty.Register("tmp", typeof (Rect), typeof (Window), new PropertyMetadata(new PropertyChangedCallback(tmpChanged)));
            this.SetResourceReference(tmp, SystemParameters.WorkAreaKey);

In this way you can subscribe to notifications of a DynamicResource when you have to convert the value.

Posted in wpf | No Comments »