Autor Beitrag
DevInet
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43

Win XP, Win 7 Prof., Linux Mandriva
C#(VS 2010), Java, php
BeitragVerfasst: Do 11.11.10 09:52 
Hallo zusammen.

Ich habe mein Programm jetzt "veröffentlicht" und mal bei mir installiert.
Nun bekomme ich beim ausführenm des Programmes folgenden Fehler:
user defined image

Unter den Details im Error-Frame steht folgendes:

ausblenden volle Höhe Quelltext
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:
Informationen über das Aufrufen von JIT-Debuggen
anstelle dieses Dialogfelds finden Sie am Ende dieser Meldung.

************** Ausnahmetext **************
System.IndexOutOfRangeException: Der Index war außerhalb des Arraybereichs.
   bei Mail_Footer_Frontend.Form4.btn1_Click(Object sender, EventArgs e) in C:\Dokumente und Einstellungen\hes\Eigene Dateien\Visual Studio 2010\Projects\Mail-Footer-Frontend\Mail-Footer-Frontend\Form4.cs:Zeile 253.
   bei System.Windows.Forms.Control.OnClick(EventArgs e)
   bei System.Windows.Forms.Button.OnClick(EventArgs e)
   bei System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   bei System.Windows.Forms.Control.WndProc(Message& m)
   bei System.Windows.Forms.ButtonBase.WndProc(Message& m)
   bei System.Windows.Forms.Button.WndProc(Message& m)
   bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Geladene Assemblys **************
mscorlib
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.1 (RTMRel.030319-0100).
    CodeBase: file:///C:/windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll.
----------------------------------------
Mail-Footer-Frontend
    Assembly-Version: 1.0.0.0.
    Win32-Version: 1.0.0.0.
    CodeBase: file:///C:/Dokumente%20und%20Einstellungen/hes/Eigene%20Dateien/Visual%20Studio%202010/Projects/Mail-Footer-Frontend/Mail-Footer-Frontend/bin/Debug/Mail-Footer-Frontend.exe.
----------------------------------------
System.Windows.Forms
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.1 built by: RTMRel.
    CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll.
----------------------------------------
System.Drawing
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.1 built by: RTMRel.
    CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll.
----------------------------------------
System
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.1 built by: RTMRel.
    CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll.
----------------------------------------
mscorlib.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.1 (RTMRel.030319-0100).
    CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_de_b77a5c561934e089/mscorlib.resources.dll.
----------------------------------------
System.Windows.Forms.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.1 built by: RTMRel.
    CodeBase: file:///C:/windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_de_b77a5c561934e089/System.Windows.Forms.resources.dll.
----------------------------------------

************** JIT-Debuggen **************
Um das JIT-Debuggen (Just-In-Time) zu aktivieren, muss in der
Konfigurationsdatei der Anwendung oder des Computers
(machine.config) der jitDebugging-Wert im Abschnitt system.windows.forms festgelegt werden.
Die Anwendung muss mit aktiviertem Debuggen kompiliert werden.

Zum Beispiel:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

Wenn das JIT-Debuggen aktiviert ist, werden alle nicht behandelten
Ausnahmen an den JIT-Debugger gesendet, der auf dem
Computer registriert ist, und nicht in diesem Dialogfeld behandelt.


Kann einer von euch was damit anfangen?
Danke im vorraus.

Mfg
DevInet
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 11.11.10 10:09 
Der Fehler steht ja da: "Der Index war außerhalb des Arraybereichs."

Und wo er aufgetreten ist auch: "bei Mail_Footer_Frontend.Form4.btn1_Click(Object sender, EventArgs e) in C:\Dokumente und Einstellungen\hes\Eigene Dateien\Visual Studio 2010\Projects\Mail-Footer-Frontend\Mail-Footer-Frontend\Form4.cs:Zeile 253"

Ohne zu wissen, was in der Zeile (und drum herum) steht, kann man da wohl nicht helfen :nixweiss:

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
DevInet Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43

Win XP, Win 7 Prof., Linux Mandriva
C#(VS 2010), Java, php
BeitragVerfasst: Do 11.11.10 10:28 
Dies ist der Code-Teil wo der Fehler angeblich steckt

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
foreach (string item2 in line3)
{
  char[] splitter = { ';' };
  string[] line2 = new string[5];
  line2 = item2.Split(splitter);
  for (int i = 0; i < 5; i++)
  {
     if (i != 1)
     {
       continue;
     }
     else
     {
       string name = line2[1];
       string ersatz = Regex.Replace(entry, exp, name);
       schleife1.WriteLine(ersatz);
     }
  }
}
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 11.11.10 10:46 
Du initialisierst das Array line2 zwar mit fünf Elementen, überschreibst es in der nächsten Zeile ("Split") direkt wieder. Wenn die Split-Anweisung nur vier Elemente zurückliefert, greifst Du in der nachfolgenden Schleife auf einen Arrayindex zu, der nicht existiert.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
DevInet Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43

Win XP, Win 7 Prof., Linux Mandriva
C#(VS 2010), Java, php
BeitragVerfasst: Do 11.11.10 10:56 
Eigentlich sollte die Split-Anweisung 5 Elemente zurückliefern.
Wenn ich nen Split mache müsste doch eigentlich "item2" nach den Semikolon getrennt werden, also 5 elemente von [0] bis [4], oder irre ich mich da so sehr?
bakachan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 503
Erhaltene Danke: 34

W7 (x64) Ultimate
C# / VB.NET (VS2010 Ultimate)
BeitragVerfasst: Do 11.11.10 10:59 
Anscheinend hat dein item2 in dem Fall aber keine 4 Semikolon
DevInet Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43

Win XP, Win 7 Prof., Linux Mandriva
C#(VS 2010), Java, php
BeitragVerfasst: Do 11.11.10 11:10 
Hmm. hab mir gerade mal die Dateien angesehen, die er eigentlich dafür nutzen soll.
Wieso ersetzt der Streamwriter ein ";" mit "+ADs-"?
Folgender Code steht hinter der .csv-bearbeitung

ausblenden volle Höhe C#-Quelltext
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:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Text.RegularExpressions;


namespace Mail_Footer_Frontend
{
    

    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
            //Einlesen der Mitarbeiter-Liste aus der Datei mitarbeiter.csv
            StreamReader eread = new StreamReader(@"R:\vorlagen\E-Mail Signatur NG\templates\events.csv", System.Text.Encoding.UTF7, true);
            {
                //Löschen des aktuellen Inhalts aus der ListBox
                eBox.Items.Clear();
                string line;
                //Überprüfung auf Leerzeilen
                while ((line = eread.ReadLine()) != null)
                {
                    //Ausgabe der Liste in der ListBox
                    eBox.Items.Add(line);
                }
            }
            eread.Close();
            Sorti();
        }

        private void Sorti()
        {
            eBox.Sorted = false;
            ArrayList arl = ArrayList.Adapter(eBox.Items);
            arl.RemoveAt(arl.Count - 1);
            arl.Sort(new IntSorter());
            arl.Add("" + ";" + "http://www.beliebige-url.de/" + ";" + "Veranstaltungsüberblick");
            //eBox.Refresh();
        }

        
       
        private void btn1_Click(object sender, EventArgs e)
        {
            //Benennung der TextBox-Inhalte
            string devent = dBox.Text;
            string web = webBox.Text;
            string titel = titelBox.Text;
            string exp = "" + ";" + "http://www.beliebige-url.de/" + ";" + "Veranstaltungsüberblick";
            //Hinzufügen der TextBox-Inhalte in die Eventliste "events.csv"

            eBox.Items.RemoveAt(eBox.Items.Count - 1);
            eBox.Items.Add(devent + ";" + web + ";" + titel);
            eBox.Items.Add(exp);
            Sorti();

            StreamWriter mwrite = new StreamWriter(@"R:\vorlagen\E-Mail Signatur NG\templates\events1.csv"true, System.Text.Encoding.UTF7);
            System.Collections.IEnumerator entryItr = eBox.Items.GetEnumerator();
            while (entryItr.MoveNext())
            {
                string entry = entryItr.Current.ToString();
                mwrite.WriteLine(entry);                                
            }
            mwrite.Close();            

            string path = @"R:\vorlagen\E-Mail Signatur NG\templates\events.csv";
            string path2 = @"R:\vorlagen\E-Mail Signatur NG\templates\events1.csv";
            // Ensure that the target does not exist.
            if (File.Exists(path))
                File.Delete(path);     
            // Move the file.
            File.Move(path2, path);

            StreamReader eread1 = new StreamReader(@"R:\vorlagen\E-Mail Signatur NG\templates\events.csv", System.Text.Encoding.UTF7, true);
            {
                //Löschen des aktuellen Inhalts aus der ListBox
                eBox.Items.Clear();
                string line;
                //Überprüfung auf Leerzeilen
                while ((line = eread1.ReadLine()) != null)
                {
                    //Ausgabe der Liste in der ListBox
                    eBox.Items.Add(line);
                }
            }
            eread1.Close();            
        }

        private void btn2_Click(object sender, EventArgs e)
        {   
            //Benennung der TextBox-Inhalte
            string devent = dBox.Text;
            string web = webBox.Text;
            string titel = titelBox.Text;
            string exp = "" + ";" + "http://www.beliebige-url.de/" + ";" + "Veranstaltungsüberblick";
            int zNr = eBox.SelectedIndex;
            string miAlt = eBox.Items[zNr].ToString();           
            eBox.Items.RemoveAt(eBox.Items.Count - 1);
            ArrayList aR = new ArrayList();
            foreach(string Item in eBox.Items)
            {
                if (Item != miAlt)
                {
                    aR.Add(Item);
                }
                else
                {
                    string ersatz = Regex.Replace(Item, miAlt, devent + ";" + web + ";" + titel);
                    aR.Add(ersatz);
                }
            }
            eBox.Items.Clear();
            eBox.Refresh();
            foreach (string itNew in aR)
            {
                eBox.Items.Add(itNew);
            }
            eBox.Refresh();
            eBox.Items.Add(exp);
            Sorti();

            StreamWriter schleife = new StreamWriter(@"R:\vorlagen\E-Mail Signatur NG\templates\events2.csv"true, System.Text.Encoding.UTF7);
            System.Collections.IEnumerator entryItr2 = eBox.Items.GetEnumerator();
            while (entryItr2.MoveNext())
            {
                string entry2 = entryItr2.Current.ToString();                
                schleife.WriteLine(entry2);           
            }
            schleife.Close();
            
            string path = @"R:\vorlagen\E-Mail Signatur NG\templates\events.csv";
            string path2 = @"R:\vorlagen\E-Mail Signatur NG\templates\events2.csv";            
            // Ensure that the target does not exist.
            if (File.Exists(path))
                File.Delete(path);
            // Move the file.
            File.Move(path2, path);

            StreamReader eread2 = new StreamReader(@"R:\vorlagen\E-Mail Signatur NG\templates\events.csv", System.Text.Encoding.UTF7, true);
            {
                //Löschen des aktuellen Inhalts aus der ListBox
                eBox.Items.Clear();
                string line;
                //Überprüfung auf Leerzeilen
                while ((line = eread2.ReadLine()) != null)
                {
                    //Ausgabe der Liste in der ListBox
                    eBox.Items.Add(line);
                }
            }
            eread2.Close();
        }

        private void btn3_Click(object sender, EventArgs e)
        {          
            string exp = "" + ";" + "http://www.beliebige-url.de/" + ";" + "Veranstaltungsüberblick";
            while (eBox.SelectedItems.Count > 0)
            {
                if (eBox.SelectedItem.ToString() != exp)
                {
                    eBox.Items.Remove(eBox.SelectedItem);
                }
                else
                {
                    eBox.Items.Remove(eBox.SelectedItem);
                    eBox.Items.Add(exp);
                }
            }

            StreamWriter schleife = new StreamWriter(@"R:\vorlagen\E-Mail Signatur NG\templates\events3.csv"true, System.Text.Encoding.UTF7);
            System.Collections.IEnumerator entryItr = eBox.Items.GetEnumerator();            
                while (entryItr.MoveNext())
                {
                        schleife.WriteLine(entryItr.Current.ToString());
                }
            schleife.Close();

            string path = @"R:\vorlagen\E-Mail Signatur NG\templates\events.csv";
            string path2 = @"R:\vorlagen\E-Mail Signatur NG\templates\events3.csv";                        
            // Ensure that the target does not exist.
            if (File.Exists(path))
                File.Delete(path);
            // Move the file.
            File.Move(path2, path);

            StreamReader eread3 = new StreamReader(@"R:\vorlagen\E-Mail Signatur NG\templates\events.csv", System.Text.Encoding.UTF7, true);
            {
                //Löschen des aktuellen Inhalts aus der ListBox
                eBox.Items.Clear();
                string line;
                //Überprüfung auf Leerzeilen
                while ((line = eread3.ReadLine()) != null)
                {
                    //Ausgabe der Liste in der ListBox
                    eBox.Items.Add(line);
                }
            }
            eread3.Close();
        }


        private void btn5_Click(object sender, EventArgs e)
        {
            int zNr1 = eBox.SelectedIndex;
            if (zNr1 >= 0)
            {
                string miAlt1 = eBox.Items[zNr1].ToString();
                char[] split1 = { ';' };
                string[] miArr1 = new string[3];
                miArr1 = miAlt1.Split(split1);
                dBox.Text = miArr1[0];
                webBox.Text = miArr1[1];
                titelBox.Text = miArr1[2];
            }
            dBox.Refresh();
            webBox.Refresh();
            titelBox.Refresh();            
        }
    }
}
bakachan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 503
Erhaltene Danke: 34

W7 (x64) Ultimate
C# / VB.NET (VS2010 Ultimate)
BeitragVerfasst: Do 11.11.10 11:31 
Nimms mir nicht übel aber mir ist das grad zu viel Code zum durchschauen.

Allgemein ist es meistens ein Encoding-Problem wenn etwas nicht so wie geschrieben wird wie du es willst.

Debug doch einfach mal Schritt für Schritt durch und schau nach ob beim Schreiben auch die richtigen Werte in den Variablen sind.