public void TimerOnTick(object obj, EventArgs ea) { string url2 = baba(); Object o = null; iexplorer.Navigate(url2, ref o, ref o, ref o, ref o); }
while((url2=file.ReadLine())!=null)
if(currentLine==randomNum) { file.Close(); }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionpublic void TimerOnTick(object obj, EventArgs ea) { baba(); Object o = null; iexplorer.Navigate(url2, ref o, ref o, ref o, ref o); } public string baba() { string url2; int currentLine = 0; StreamReader file = new StreamReader("sites.txt"); Random generator = new Random(); int randomNum = Convert.ToInt32((getNumberOfLines()*generator.NextDouble())+1); while((url2=file.ReadLine())!=null) { currentLine++; if(currentLine==randomNum) { file.Close(); } } return url2; }
See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ************** Exception Text ************** System.ObjectDisposedException: Cannot read from a closed TextReader. at System.IO.__Error.ReaderClosed() at System.IO.StreamReader.ReadLine() at Iexplore_tests.Form1.baba() at Iexplore_tests.Form1.TimerOnTick(Object obj, EventArgs ea) at System.Windows.Forms.Timer.OnTick(EventArgs e) at System.Windows.Forms.Timer.Callback(IntPtr hWnd, Int32 msg, IntPtr idEvent, IntPtr dwTime) ************** Loaded Assemblies ************** mscorlib Assembly Version: 1.0.5000.0 Win32 Version: 1.1.4322.573 CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll ---------------------------------------- IexploreAutomation Assembly Version: 1.0.1656.19791 Win32 Version: 1.0.1656.19791 CodeBase: file:///C:/Frederic/Projets/C%23/Iexplore%20tests/Iexplore%20tests/bin/Release/IexploreAutomation.exe ---------------------------------------- System.Windows.Forms Assembly Version: 1.0.5000.0 Win32 Version: 1.1.4322.573 CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll ---------------------------------------- System Assembly Version: 1.0.5000.0 Win32 Version: 1.1.4322.573 CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll ---------------------------------------- System.Drawing Assembly Version: 1.0.5000.0 Win32 Version: 1.1.4322.573 CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll ---------------------------------------- Interop.SHDocVw Assembly Version: 1.1.0.0 Win32 Version: 1.1.0.0 CodeBase: file:///C:/Frederic/Projets/C%23/Iexplore%20tests/Iexplore%20tests/bin/Release/Interop.SHDocVw.DLL ---------------------------------------- ************** JIT Debugging ************** To enable just in time (JIT) debugging, the config file for this application or machine (machine.config) must have the jitDebugging value set in the system.windows.forms section. The application must also be compiled with debugging enabled. For example: <configuration> <system.windows.forms jitDebugging="true" /> </configuration> When JIT debugging is enabled, any unhandled exception will be sent to the JIT debugger registered on the machine rather than being handled by this dialog.
while((url2=file.ReadLine())!=null) { if(currentLine==randomNum) { file.Close(); } return url2; }
while((url2=file.ReadLine())!=null) { currentLine++; if(currentLine==randomNum) { return url2; } } return url2;
Object reference not set to an instance of an object.
Object reference not set to an instance of an object.
private void something() { int avariable = 1 } private void somethingelse() { avariable = 2 }