Hallo Forummitglieder,
Ich habe eine kleine eigene Messagebox erstellt, die als Alternative in einer Anwendung Warnmeldungen erzeugt.
Diese sollte als STAThread aufgerufen werden.
Es werden dabei 2 Strings übergeben.
Ich bin schon seit tagen am googeln und habe schon sämtliche Verweise auf ähnliche Probleme strikt durchgearbeitet aber ich kann den Fehler nicht beheben.
Hier der relevante Teil des Codes:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83:
| namespace Mainproject.WPFMessageBoxControls { internal delegate void Invoker();
public partial class WPFMessageBox : Window { #region Constants private const int YES_ID = 356; private const int NO_ID = 357; private const int OK_ID = 65; private const int CANCEL_ID = 64; public string strText; public string strCaption; public string strTextNew; public string strCaptionNew; public string[] strTC; public object data;
#endregion
#region variables #endregion
[ThreadStatic] public static WPFMessageBox _msgBox; public string strYes, strCancel, strOk, StrNo;
public WPFMessageBox(string strText, string strCaption) {
InitializeComponent(); this.tblMessage.Text = strText; this.lblMsgWndHeader.Content = strCaption; this.InitializeMultiLangText(); this.OnLanguageChanged();
}
[STAThread] public static void ThreadProc(object data) { object[] ParamArray = (object[])data; string strText = (string)data[1]; string strCaption = (string)data[2]; WPFMessageBox WPFMBox = new WPFMessageBox(strText, strCaption); _msgBox.ShowDialog(); }
[STAThread] public static bool? ShowMessage(string strText, string strCaption, WFPMessageBoxButtons msgBxBtn, MessageBoxImage image)
{ Thread newThreadProc = new Thread (new ParameterizedThreadStart(WPFMessageBox.ThreadProc));
string strTextNew = strText; string strCaptionNew = strCaption; object[] data = new object[] { strTextNew, strCaptionNew }; newThreadProc.SetApartmentState(ApartmentState.STA); newThreadProc.Name = "STAThread"; newThreadProc.Start(_msgBox.data);
if (System.Windows.Application.Current.Properties["MainWindow"] is Window) { Window wndw = System.Windows.Application.Current.Properties["MainWindow"] as Window; _msgBox.Owner = System.Windows.Application.Current.Properties["MainWindow"] as Window; }
UpdateUI(msgBxBtn); _msgBox.Close(); return _msgBox.DialogResult; } |
Die Fehlermeldung lautet:
Cannot apply indexing with [] to an expression of type 'object'
Kann mir jemand etwas Licht ins Dunkel bringen???
Herzlichen Dank
Gruss Markus ---marix---