März 2009 - Einträge

Uni Stuttgart: WPF Vortrag

Hier gibt es die Slides, Sourcen und Aufgaben zum WPF Vortrag vom 25.03.2009.

Slides + Sourcen
http://vb-magazin.de/janm/WPF-Vortrag.zip

Aufgaben
http://vb-magazin.de/janm/Aufgaben.pdf

Zum Weiterlesen

WPF DataBinding Blog
http://bea.stollnitz.com/blog/

Family Show
http://www.vertigo.com/familyshow.aspx

WPF Toolkit
http://wpf.codeplex.com/

KaXaml
http://www.kaxaml.com/

Posted von Jan-Cornelius Molnar mit no comments
Abgelegt unter: , ,

Web Platfrom Installer geht in die zweite Runde

Auf der MIX wurde die Beta der Version 2 des Web Platform Installers angekündigt. Das Tool übernimmt die Installation des .NET Frameworks, IIS mit Erweiterungen, Sql Server Express und Visual Web Developer und kann einem damit viele Stunden Arbeit beim Aufsetzen einer Entwicklungs oder sogar Produktivumgebung sparen und das alles in einem 1MB Download.

Natürlich lässt sich jede Komponente einzeln auswählen und konfigurieren.

In Version 2 ist außerdem noch die Installation von beliebten Anwendungen wie DotNetNuke und WordPress möglich, sowie die Bereitstellung der neusten PHP Version als PHP für Windows!

Das Tool unterstützt Windows XP SP2+, Windows Vista SP1, Windows Server 2003 SP1+ und Windows Server 2008.

Download
http://www.microsoft.com/web/downloads/platform.aspx

Sql Server ExceptionMessageBox in WPF nutzen

Wer das Microsoft Sql Management Studio verwendet kennt sie vielleicht, die ExceptionMessageBox des Sql Servers. Sie bietet eine gute Übersicht über alle relevanten Informationen einer Exception und das Beste ist, dass sie als Assembly in jedes .NET Projekt eingebunden und damit in jeder .NET Anwendung angezeigt werden kann.

image

Einziger Haken: Zur Anzeige der ExceptionMessageBox wird ein owner vom Typ System.Windows.Forms.IWin32Owner erwartet. Bewegt man sich in WPF, steht dieser einem natürlich nicht zur Verfügung. Abhilfe schafft der Typ ExceptionMessageBoxParent, da dieser mit einem gewöhnlichen Handle erstellt werden und somit als IWin32Owner verwendet werden kann.

Mit den WPF Interop Tools kann somit die ExceptionMessageBox problemlos in WPF einbinden.

   1:      public class ExceptionMessageBoxWpf : ExceptionMessageBox
   2:      {
   3:          public ExceptionMessageBoxWpf() : base() { }
   4:          public ExceptionMessageBoxWpf(Exception exception) : base(exception) { }
   5:          public ExceptionMessageBoxWpf(string text) : base(text) { }
   6:          public ExceptionMessageBoxWpf(Exception exception, ExceptionMessageBoxButtons buttons) : base(exception, buttons) { }
   7:          public ExceptionMessageBoxWpf(string text, string caption) : base(text, caption) { }
   8:          public ExceptionMessageBoxWpf(Exception exception, ExceptionMessageBoxButtons buttons, ExceptionMessageBoxSymbol symbol) : base(exception, buttons, symbol) { }
   9:          public ExceptionMessageBoxWpf(string text, string caption, ExceptionMessageBoxButtons buttons) : base(text, caption, buttons) { }
  10:          public ExceptionMessageBoxWpf(Exception exception, ExceptionMessageBoxButtons buttons, ExceptionMessageBoxSymbol symbol, ExceptionMessageBoxDefaultButton defaultButton) : base(exception, buttons, symbol, defaultButton) { }
  11:          public ExceptionMessageBoxWpf(string text, string caption, ExceptionMessageBoxButtons buttons, ExceptionMessageBoxSymbol symbol) : base(text, caption, buttons, symbol) { }
  12:          public ExceptionMessageBoxWpf(Exception exception, ExceptionMessageBoxButtons buttons, ExceptionMessageBoxSymbol symbol, ExceptionMessageBoxDefaultButton defaultButton, ExceptionMessageBoxOptions options) : base(exception, buttons, symbol, defaultButton, options) { }
  13:          public ExceptionMessageBoxWpf(string text, string caption, ExceptionMessageBoxButtons buttons, ExceptionMessageBoxSymbol symbol, ExceptionMessageBoxDefaultButton defaultButton) : base(text, caption, buttons, symbol, defaultButton) { }
  14:          public ExceptionMessageBoxWpf(string text, string caption, ExceptionMessageBoxButtons buttons, ExceptionMessageBoxSymbol symbol, ExceptionMessageBoxDefaultButton defaultButton, ExceptionMessageBoxOptions options) : base(text, caption, buttons, symbol, defaultButton, options) { }
  15:   
  16:          public void Show(Window owner) {
  17:              // the owner window is required
  18:              if (owner == null) throw new ArgumentNullException("owner");
  19:   
  20:              Type exbParentType;
  21:              Type exbType;
  22:              System.Windows.Interop.WindowInteropHelper helper;
  23:   
  24:              // The ExceptionMessageBox Show method requires a owner which implements
  25:              // System.Windows.Forms.IWin32Window - the WPF Windows don't do that
  26:              // but we can use the internal class ExceptionMessageBoxParent
  27:              // the create a appropriate owner.
  28:              exbParentType = Type.GetType("Microsoft.SqlServer.MessageBox.ExceptionMessageBoxParent, Microsoft.ExceptionMessageBox, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91");
  29:              exbType = this.GetType();
  30:   
  31:              // WindowInteropHelper allows access to the root handle of the wpf window.
  32:              helper = new System.Windows.Interop.WindowInteropHelper(owner);
  33:   
  34:              IWin32Window parent = (IWin32Window)Activator.CreateInstance(exbParentType, new object[] { helper.Handle });
  35:   
  36:              this.Show(parent);
  37:          }
  38:  }

Als Parameter lässt sich somit jedes WPF Window übergeben.

   1:              try {
   2:                  throw new ApplicationException("Hello from WPF!");
   3:              } catch (Exception ex) {
   4:                  ExceptionMessageBoxWpf ebx = new ExceptionMessageBoxWpf(ex);
   5:                  ebx.Show(this);
   6:                  throw;
   7:              }
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

Die ExceptionMessageBox ist jedoch erstaunlich vielseitig und lässt sich auch für Meldungen jeglicher Art verwenden (siehe [2]).

Zum Weiterlesen

[1] How to: Program Exception Message Box (MSDN)
http://msdn.microsoft.com/en-us/library/ms166340.aspx

[2] Make your exceptions shine with SQL Server Exception Message Box
http://geekswithblogs.net/kobush/archive/2006/05/21/ExceptionMessageBox.aspx

Posted von Jan-Cornelius Molnar mit 1 comment(s)
Abgelegt unter: , ,