Autor |
Beitrag |
Marmelade
      
Beiträge: 39
Windows XP, Windows7 Ultimate
C#
|
Verfasst: Sa 18.04.09 23:44
Moin,
Tja bis vor ein paar minuten ging noch alles gut und das Programm läuft sauber durch.
Jetzt, nachdem ich nichts gemacht habe außer nen neuen Struct hinzuzufügen, spuckt's mir folgenden error aus:
"TargetInvocationException wurde nicht behandelt
Ein Aufrufziel hat einen Ausnahmefehler verursacht"
Hatte jemand von euch schonmal diesen fehler? Ich weiß nicht wie ich den beheben kann und in der Onlinehilfe steht auch nur:
"Diese Ausnahme wird von Methoden ausgelöst, die durch Reflektion aufgerufen werden."
Hier mein Code:
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:
| using System; 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.Net.NetworkInformation; using System.Threading; using System.Net.Sockets; using System.Text.RegularExpressions;
namespace WindowsFormsApplication1 { public partial class Form1 : Form { public struct connectargs { public string ip; public int portfrom,portto;
public connectargs(string addr, int prtfrm, int prtto) { ip=addr; portfrom=prtfrm; portto = prtto; } }
public struct portstat { public string status; public int number;
public portstat(string stat, int num) { status = stat; number = num; } }
public Form1() { InitializeComponent(); } private bool portscan(String ip, int port) {
TcpClient tcpc = new TcpClient();
try { tcpc.Connect(ip, port); } catch (SocketException) { return false; } return true; }
private void ipscan() { Ping pingSender = new Ping(); PingOptions options = new PingOptions();
options.DontFragment = true;
for (int id = 0; id < 255; id++) { string aktip; string netz; string data; string idstr; int tout = 60;
netz = "192.168.178."; aktip = netz + id.ToString(); idstr = id.ToString(); data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
byte[] buffer = Encoding.ASCII.GetBytes(data); PingReply reply = pingSender.Send(aktip, tout, buffer, options); if (reply.Status == IPStatus.Success) { backgroundWorker1.ReportProgress(0, aktip); } } button1.Enabled = true; }
public void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { ipscan(); }
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e) { listBox1.Items.Add(e.UserState); }
private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e) { connectargs m = (connectargs)e.Argument; portstat p = new portstat(); string ip = m.ip; int fromport = m.portfrom; int toport = m.portto;
for (int aktport = fromport; aktport <= toport; aktport++) { if (portscan(ip, aktport)) { p.number = aktport; p.status = aktport + " open"; backgroundWorker2.ReportProgress(80,p); } else { p.number = aktport; p.status = aktport + " closed"; backgroundWorker2.ReportProgress(90, aktport + " closed"); } } }
private void backgroundWorker2_ProgressChanged(object sender, ProgressChangedEventArgs e) { portstat p = (portstat)e.UserState; ping_label.Text = p.number.ToString(); listBox2.Items.Add(p.status); }
private void button1_Click(object sender, EventArgs e) {
this.backgroundWorker1.RunWorkerAsync();
backgroundWorker1.WorkerSupportsCancellation = true; }
private void button2_Click(object sender, EventArgs e) { backgroundWorker1.CancelAsync(); }
private void button3_Click(object sender, EventArgs e) { string ip; int portfrom, portto; portfrom = Convert.ToInt32(textBox2.Text); portto = Convert.ToInt32(textBox3.Text); ip = textBox1.Text;
connectargs dat = new connectargs(ip,portfrom, portto); backgroundWorker2.RunWorkerAsync(dat); }
private void button4_Click(object sender, EventArgs e) { backgroundWorker2.CancelAsync(); }
private void iPsScannenToolStripMenuItem_Click(object sender, EventArgs e) { this.backgroundWorker1.RunWorkerAsync(); } private void listBox1_DoubleClick(object sender, EventArgs e) { string ip; ip=listBox1.SelectedItem.ToString(); connectargs dat = new connectargs(ip, 20, 200); backgroundWorker2.RunWorkerAsync(dat); }
private void portsScannenToolStripMenuItem_Click(object sender, EventArgs e) { string ip; ip = listBox1.SelectedItem.ToString(); connectargs dat = new connectargs(ip, 20, 200); backgroundWorker2.RunWorkerAsync(dat); } } } |
|
|
Kha
      
Beiträge: 3803
Erhaltene Danke: 176
Arch Linux
Python, C, C++ (vim)
|
Verfasst: So 19.04.09 00:40
Wird denn eine Zeile markiert? Wenn nicht, poste am besten den gesamten StackTrace der Exception, denn mir ist auch nicht klar, was sie eigentlich auslöst.
TargetInvocationException besitzt auch immer eine InnerException, die wäre ebenfalls interessant.
_________________ >λ=
|
|
Marmelade 
      
Beiträge: 39
Windows XP, Windows7 Ultimate
C#
|
Verfasst: So 19.04.09 12:08
Okay
Also es wird mir die Zeile:
C#-Quelltext 1:
| Application.Run(new Form1()); |
markiert.
DIe InnerExceptions sehen folgendermaßen aus:
System.InvalidCastException
"Beim umwandeln einer Zahl muss der Wert eine zahl sein, die kleiner als unendlich ist"
"Stellen sie sicher, dass der Quellentyp in den Zieltyp konvertiert werden kann"
Hab auch schon nach so einer Zahl bei mir gesucht, aber keine gefunden.
|
|
jaenicke
      
Beiträge: 19312
Erhaltene Danke: 1747
W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: So 19.04.09 12:16
Ich vermute einmal den Fehler in backgroundWorker2_ProgressChanged (p.number.ToString), nimm die drei Zeilen mal einfach raus und schau, ob der Fehler immer noch auftritt.
Um das genau sagen zu können, fehlt wie gesagt der StackTrace.
|
|
Marmelade 
      
Beiträge: 39
Windows XP, Windows7 Ultimate
C#
|
Verfasst: So 19.04.09 12:30
Cool Danke!
Genau da lag der fehler.
Hat da noch wer ne Idee wie ich den Fehler beheben kann?
|
|
Marmelade 
      
Beiträge: 39
Windows XP, Windows7 Ultimate
C#
|
Verfasst: So 19.04.09 12:38
Achso ja der StackTrace
bei System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
bei System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
bei System.Convert.ToInt32(String value)
bei WindowsFormsApplication1.Form1.button3_Click(Object sender, EventArgs e) in C:\Dokumente und Einstellungen\Mattes\Eigene Dateien\Visual Studio 2008\Projects\NetSpy\NetSpyW32\NetSpyW32\Form1.cs:Zeile 161.
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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
bei System.Windows.Forms.Application.Run(Form mainForm)
bei WindowsFormsApplication1.Program.Main() in C:\Dokumente und Einstellungen\Mattes\Eigene Dateien\Visual Studio 2008\Projects\NetSpy\NetSpyW32\NetSpyW32\Program.cs:Zeile 18.
bei System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart()
|
|
jaenicke
      
Beiträge: 19312
Erhaltene Danke: 1747
W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: So 19.04.09 12:46
Da steht doch deutlich drin, dass der Fehler hier aufgetreten ist, in der TextBox war also was Falsches drin... C#-Quelltext 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167:
| /* ... */ private void button3_Click(object sender, EventArgs e) { string ip; int portfrom, portto; portfrom = Convert.ToInt32(textBox2.Text); portto = Convert.ToInt32(textBox3.Text); ip = textBox1.Text;
connectargs dat = new connectargs(ip,portfrom, portto); backgroundWorker2.RunWorkerAsync(dat); } |
Marmelade hat folgendes geschrieben : | bei System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
bei System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
bei System.Convert.ToInt32(String value)
bei WindowsFormsApplication1.Form1.button3_Click(Object sender, EventArgs e) in C:\Dokumente und Einstellungen\Mattes\Eigene Dateien\Visual Studio 2008\Projects\NetSpy\NetSpyW32\NetSpyW32\Form1.cs:Zeile 161.
[...] |
Aber bist du sicher, dass das der Stacktrace zum selben Fehler ist? 
|
|
Marmelade 
      
Beiträge: 39
Windows XP, Windows7 Ultimate
C#
|
Verfasst: So 19.04.09 12:53
Okay, danke.
Hab grade irgendwie nicht richtig nachgedacht.
Und wegen dem StackTrace, der gehört zu dem Fehler.
|
|
jaenicke
      
Beiträge: 19312
Erhaltene Danke: 1747
W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: So 19.04.09 12:55
Dann benutze einfach TryParse an der Stelle und alles ist gut. Das gibt dann keinen Fehler, wenn die Umwandlung des Strings nicht klappt sondern gibt dir das nur zurück.
|
|
Marmelade 
      
Beiträge: 39
Windows XP, Windows7 Ultimate
C#
|
Verfasst: So 19.04.09 13:12
Okay danke!
EDIT:
Mist!
Ich hab das jetzt mit
C#-Quelltext 1: 2: 3: 4:
| int portfrom; int portto; Int32.TryParse(textBox2.Text,out portfrom); Int32.TryParse(textBox3.Text, out portto); |
versucht. Der Fehler kommt aber immer noch obwohl ich normal in die Textboxes ne Zahl wie 20 oder 23 eingebe.
Auch wenn ich den Variablen einfach so Zahlen zuweise, geht dass nicht.
|
|
Marmelade 
      
Beiträge: 39
Windows XP, Windows7 Ultimate
C#
|
Verfasst: So 19.04.09 19:29
Wieß denn keiner was das sein könnte?
Ich selber hab nämlich auch kp mehr.
|
|
jaenicke
      
Beiträge: 19312
Erhaltene Danke: 1747
W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: So 19.04.09 19:53
Hast du das ProgressChanged wieder drin? Ich hatte ja deshalb gefragt, ob das der StackTrace von der anfänglichen Fehlermeldung ist, weil das eigentlich nicht so recht passte.
|
|
Marmelade 
      
Beiträge: 39
Windows XP, Windows7 Ultimate
C#
|
Verfasst: So 19.04.09 20:35
Jop hab ich wieder drin
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:
| namespace WindowsFormsApplication1 { public partial class Form1 : Form { public struct connectargs { public string ip; public int portfrom, portto;
public connectargs(string addr, int prtfrm, int prtto) { ip = addr; portfrom = prtfrm; portto = prtto; } }
public struct portstat { public string status; public int number;
public portstat(string stat, int num) { status = stat; number = num; } }
public Form1() { InitializeComponent(); }
private bool portscan(String ip, int port) {
TcpClient tcpc = new TcpClient();
try { tcpc.Connect(ip, port); } catch (SocketException) { return false; } return true; }
private void ipscan() { Ping pingSender = new Ping(); PingOptions options = new PingOptions();
options.DontFragment = true;
for (int id = 0; id < 255; id++) {
string aktip; string netz; string data; string idstr; int tout = 60;
netz = "192.168.178."; aktip = netz + id.ToString(); idstr = id.ToString(); data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
byte[] buffer = Encoding.ASCII.GetBytes(data); PingReply reply = pingSender.Send(aktip, tout, buffer, options);
if (reply.Status == IPStatus.Success) { backgroundWorker1.ReportProgress(0, aktip); } } button1.Enabled = true; }
public void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { ipscan(); }
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e) { listBox1.Items.Add(e.UserState); }
private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e) { connectargs con = (connectargs)e.Argument; portstat p = new portstat();
string ip; ip = con.ip; int fromport = con.portfrom; int toport = con.portto;
for (int aktport = fromport; aktport <= toport; aktport++) { if (portscan(ip, aktport)) { p.number = aktport; p.status = aktport + " open"; backgroundWorker2.ReportProgress(80, p); } else { p.number = aktport; p.status = aktport + " closed"; backgroundWorker2.ReportProgress(90, aktport + " closed"); } } }
private void backgroundWorker2_ProgressChanged(object sender, ProgressChangedEventArgs e) { portstat pstat = (portstat)e.UserState; ping_label.Text = pstat.number.ToString(); listBox2.Items.Add(pstat.status); }
private void button1_Click(object sender, EventArgs e) {
this.backgroundWorker1.RunWorkerAsync();
backgroundWorker1.WorkerSupportsCancellation = true; }
private void button2_Click(object sender, EventArgs e) { backgroundWorker1.CancelAsync(); }
private void button3_Click(object sender, EventArgs e) { string ip; int portfrom; int portto; Int32.TryParse(textBox2.Text, out portfrom); Int32.TryParse(textBox3.Text, out portto); ip = textBox1.Text;
connectargs dat = new connectargs(ip, portfrom, portto); backgroundWorker2.RunWorkerAsync(dat); }
private void button4_Click(object sender, EventArgs e) { backgroundWorker2.CancelAsync(); }
private void iPsScannenToolStripMenuItem_Click(object sender, EventArgs e) { this.backgroundWorker1.RunWorkerAsync(); }
private void listBox1_DoubleClick(object sender, EventArgs e) { string ip; ip = listBox1.SelectedItem.ToString(); connectargs dat = new connectargs(ip, 20, 200); backgroundWorker2.RunWorkerAsync(dat); }
private void portsScannenToolStripMenuItem_Click(object sender, EventArgs e) { string ip; ip = listBox1.SelectedItem.ToString(); connectargs dat = new connectargs(ip, 20, 200); backgroundWorker2.RunWorkerAsync(dat); } } } |
|
|
jaenicke
      
Beiträge: 19312
Erhaltene Danke: 1747
W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: So 19.04.09 20:54
Dann poste doch einmal den Stacktrace (am besten in Codetags oder so  ) wenn bei gültigen Eingabewerten der anfängliche Fehler aufritt. Und ich vermute, dass da genau diese Methode drin steht. 
|
|
Marmelade 
      
Beiträge: 39
Windows XP, Windows7 Ultimate
C#
|
Verfasst: So 19.04.09 21:03
Okay hier:
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:
| bei System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) bei System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) bei System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) bei System.Delegate.DynamicInvokeImpl(Object[] args) bei System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme) bei System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj) bei System.Threading.ExecutionContext.runTryCode(Object userData) bei System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) bei System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme) bei System.Windows.Forms.Control.InvokeMarshaledCallbacks() bei System.Windows.Forms.Control.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) bei System.Windows.Forms.Application.Run(Form mainForm) bei WindowsFormsApplication1.Program.Main() in C:\Dokumente und Einstellungen\Mattes\Eigene Dateien\Visual Studio 2008\Projects\NetSpy\NetSpyW32\NetSpyW32\Program.cs:Zeile 18. bei System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() bei System.Threading.ThreadHelper.ThreadStart_Context(Object state) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) bei System.Threading.ThreadHelper.ThreadStart() |
|
|
jaenicke
      
Beiträge: 19312
Erhaltene Danke: 1747
W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: So 19.04.09 21:17
Hmm, das sagt mir nicht viel, jedenfalls nicht was die Ursache des Fehlers angeht.
Vielleicht sagen ja Kha oder andere, die sich mit C# besser als ich auskennen, etwas dazu. 
|
|
Marmelade 
      
Beiträge: 39
Windows XP, Windows7 Ultimate
C#
|
Verfasst: So 19.04.09 22:11
Okay ich werd ihn mal fragen
Trotzdem danke
|
|
Kha
      
Beiträge: 3803
Erhaltene Danke: 176
Arch Linux
Python, C, C++ (vim)
|
Verfasst: So 19.04.09 22:29
Äh, irgendwie ist das ziemlich merkwürdig  .
Um auf den neuesten Stand zu kommen: Welche Zeile wirft beim aktuellen Code nun welche Exception, welchen Stacktrace gibts bei der äußeren und inneren Exception?
Eigentlich sollte eine TargetInvocationException höchstens in den ProgressChanged-Eventhandlern auftreten. Du hast nicht zufällig ProgressChanged auf Button3_Click gelegt *g* ?
PS: Der Button hat in ipscan nichts zu suchen.
_________________ >λ=
|
|
Marmelade 
      
Beiträge: 39
Windows XP, Windows7 Ultimate
C#
|
Verfasst: Mo 20.04.09 16:50
Okay ich denke hier sollte dann alles dabei sein:
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:
| System.Reflection.TargetInvocationException wurde nicht behandelt. Message="Ein Aufrufziel hat einen Ausnahmefehler verursacht." Source="mscorlib" StackTrace: bei System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) bei System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) bei System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) bei System.Delegate.DynamicInvokeImpl(Object[] args) bei System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme) bei System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj) bei System.Threading.ExecutionContext.runTryCode(Object userData) bei System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) bei System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme) bei System.Windows.Forms.Control.InvokeMarshaledCallbacks() bei System.Windows.Forms.Control.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) bei System.Windows.Forms.Application.Run(Form mainForm) bei WindowsFormsApplication1.Program.Main() in C:\Dokumente und Einstellungen\Mattes\Eigene Dateien\Visual Studio 2008\Projects\NetSpy\NetSpyW32\NetSpyW32\Program.cs:Zeile 18. bei System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() bei System.Threading.ThreadHelper.ThreadStart_Context(Object state) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) bei System.Threading.ThreadHelper.ThreadStart() InnerException: System.InvalidCastException Message="Die angegebene Umwandlung ist ungültig." Source="NetSpyW32" StackTrace: bei WindowsFormsApplication1.Form1.backgroundWorker2_ProgressChanged(Object sender, ProgressChangedEventArgs e) in C:\Dokumente und Einstellungen\Mattes\Eigene Dateien\Visual Studio 2008\Projects\NetSpy\NetSpyW32\NetSpyW32\Form1.cs:Zeile 139. bei System.ComponentModel.BackgroundWorker.OnProgressChanged(ProgressChangedEventArgs e) bei System.ComponentModel.BackgroundWorker.ProgressReporter(Object arg) |
|
|
jaenicke
      
Beiträge: 19312
Erhaltene Danke: 1747
W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: Mo 20.04.09 17:00
Was sagte ich, da stehts doch: backgroundWorker2_ProgressChanged
Das wird offensichtlich schon da direkt am Anfang aufgerufen und da ist die Zahl oder das ganze wohl noch undefiniert.
Da ich mich mich dem BackgroundWorker nicht weiter auskenne, kann ich da aber sonst nix weiter zu sagen. 
|
|
|