|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VB.NET errorI am migrating some scripts to .NET. This has been a learning experience to say the least. The whole script pull a list of computers through an LDAP call to AD. It then writes the computer names to a file. The file is then read, pings the computer and then if it is alive, checks the OS. Private Sub ParseComputerList() 'Dim ComputerResultsFile As IO.StreamWriter = New IO.StreamWriter("C:\ComputerResults.txt") 'Dim ComputerListfile As System.IO.File Dim ComputerListreader As System.IO.StreamReader Dim PingStatus As Boolean ComputerListreader = IO.File.OpenText("C:\DomainList.txt") While ComputerListreader.Peek <> -1 Computer = ComputerListreader.ReadLine() If SystemAlive(Computer, PingStatus) Then CheckOS() ResultOutput() ProgressBar1.PerformStep() Else 'MessageBox.Show("Machine is Offline") End If End While ComputerListreader.Close() End Sub Private Sub CheckOS() 'Dim RegSubKey As Microsoft.Win32.RegistryHive Dim RegKey As RegistryKey ' Dim RegSubKey As RegistryKey Dim strOS As String Try RegKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, Computer).OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion", True) If RegKey.GetValue("CurrentVersion") = "5.1" Then strOS = "Windows XP Pro" strResult = Computer & " " & strOS 'MessageBox.Show(Computer & " Is A Windows XP System") Else End If Catch ex As Exception strOS = "Error" 'MessageBox.Show(ex.InnerException.ToString) End Try ' System.Threading.Thread.Sleep(5000) End Sub Private Sub ResultOutput() ComputerResultsFile.WriteLine(UCase(strResult)) 'ComputerResultsFile.Close() End Sub Private Function SystemAlive(ByVal Name As String, ByRef PingResult As Boolean) As Boolean Dim pingClient As New Ping Dim status As IPStatus 'Dim PingResult As Boolean PingResult = False Try status = pingClient.Send(Name, 1000).Status If status = IPStatus.Success Then PingResult = True 'StatusBar1.Text = Name & " Ping Successful" 'MessageBox.Show("Machine is on we can now do whatever") Else StatusBar1.Text = Name & " Ping TimedOut" PingResult = False 'MessageBox.Show("Can't contact machine : " & status.ToString) End If Catch ex As Exception PingResult = False 'MessageBox.Show(ex.InnerException.ToString) StatusBar1.Text = Name & " Error" End Try SystemAlive = PingResult End Function The script writes the list of computer without issue. However something breaks after that and I get the following error. The CLR has been unable to transition from COM context 0x1a0120 to COM context 0x1a0290 for 60 seconds. Thanks for any help Hi,
See: Why you sometimes get a bogus ContextSwitchDeadLock MDA under the debugger http://blogs.msdn.com/jmstall/archive/2005/11/11/ContextSwitchDeadLock.aspx You can try going to "Debug", "Exceptions..." menu, Managed Debugging Assistants and uncheck ContextSwitchDeadlock. -- Show quoteHide quoteBest regards, Carlos J. Quintero MZ-Tools: Productivity add-ins for Visual Studio You can code, design and document much faster: http://www.mztools.com "jwray" <jw***@discussions.microsoft.com> escribió en el mensaje news:80E38462-6ACF-408A-8417-63EF57E6BF13@microsoft.com... > Hello All, > > I am migrating some scripts to .NET. This has been a learning experience > to > say the least. > > The whole script pull a list of computers through an LDAP call to AD. It > then writes the computer names to a file. The file is then read, pings the > computer and then if it is alive, checks the OS. > > Private Sub ParseComputerList() > 'Dim ComputerResultsFile As IO.StreamWriter = New > IO.StreamWriter("C:\ComputerResults.txt") > 'Dim ComputerListfile As System.IO.File > Dim ComputerListreader As System.IO.StreamReader > Dim PingStatus As Boolean > > ComputerListreader = IO.File.OpenText("C:\DomainList.txt") > > While ComputerListreader.Peek <> -1 > Computer = ComputerListreader.ReadLine() > If SystemAlive(Computer, PingStatus) Then > CheckOS() > ResultOutput() > ProgressBar1.PerformStep() > > Else > 'MessageBox.Show("Machine is Offline") > End If > > End While > > ComputerListreader.Close() > > End Sub > > > Private Sub CheckOS() > 'Dim RegSubKey As Microsoft.Win32.RegistryHive > Dim RegKey As RegistryKey > ' Dim RegSubKey As RegistryKey > Dim strOS As String > > Try > RegKey = > RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, > Computer).OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion", True) > > If RegKey.GetValue("CurrentVersion") = "5.1" Then > strOS = "Windows XP Pro" > strResult = Computer & " " & strOS > 'MessageBox.Show(Computer & " Is A Windows XP System") > Else > > End If > > Catch ex As Exception > strOS = "Error" > 'MessageBox.Show(ex.InnerException.ToString) > > End Try > ' System.Threading.Thread.Sleep(5000) > End Sub > Private Sub ResultOutput() > ComputerResultsFile.WriteLine(UCase(strResult)) > 'ComputerResultsFile.Close() > End Sub > > Private Function SystemAlive(ByVal Name As String, ByRef PingResult As > Boolean) As Boolean > > Dim pingClient As New Ping > Dim status As IPStatus > 'Dim PingResult As Boolean > PingResult = False > > Try > status = pingClient.Send(Name, 1000).Status > If status = IPStatus.Success Then > PingResult = True > 'StatusBar1.Text = Name & " Ping Successful" > 'MessageBox.Show("Machine is on we can now do whatever") > Else > StatusBar1.Text = Name & " Ping TimedOut" > PingResult = False > 'MessageBox.Show("Can't contact machine : " & > status.ToString) > End If > Catch ex As Exception > PingResult = False > 'MessageBox.Show(ex.InnerException.ToString) > StatusBar1.Text = Name & " Error" > End Try > SystemAlive = PingResult > > > > End Function > > The script writes the list of computer without issue. However something > breaks after that and I get the following error. > > The CLR has been unable to transition from COM context 0x1a0120 to COM > context 0x1a0290 for 60 seconds. > > Thanks for any help > See also how to disable MDAs in the registry:
Diagnosing Errors with Managed Debugging Assistants http://msdn2.microsoft.com/en-us/library/d21c150d(VS.80).aspx -- Show quoteHide quoteBest regards, Carlos J. Quintero MZ-Tools: Productivity add-ins for Visual Studio You can code, design and document much faster: http://www.mztools.com "jwray" <jw***@discussions.microsoft.com> escribió en el mensaje news:80E38462-6ACF-408A-8417-63EF57E6BF13@microsoft.com... > Hello All, > > I am migrating some scripts to .NET. This has been a learning experience > to > say the least. > > The whole script pull a list of computers through an LDAP call to AD. It > then writes the computer names to a file. The file is then read, pings the > computer and then if it is alive, checks the OS. > > Private Sub ParseComputerList() > 'Dim ComputerResultsFile As IO.StreamWriter = New > IO.StreamWriter("C:\ComputerResults.txt") > 'Dim ComputerListfile As System.IO.File > Dim ComputerListreader As System.IO.StreamReader > Dim PingStatus As Boolean > > ComputerListreader = IO.File.OpenText("C:\DomainList.txt") > > While ComputerListreader.Peek <> -1 > Computer = ComputerListreader.ReadLine() > If SystemAlive(Computer, PingStatus) Then > CheckOS() > ResultOutput() > ProgressBar1.PerformStep() > > Else > 'MessageBox.Show("Machine is Offline") > End If > > End While > > ComputerListreader.Close() > > End Sub > > > Private Sub CheckOS() > 'Dim RegSubKey As Microsoft.Win32.RegistryHive > Dim RegKey As RegistryKey > ' Dim RegSubKey As RegistryKey > Dim strOS As String > > Try > RegKey = > RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, > Computer).OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion", True) > > If RegKey.GetValue("CurrentVersion") = "5.1" Then > strOS = "Windows XP Pro" > strResult = Computer & " " & strOS > 'MessageBox.Show(Computer & " Is A Windows XP System") > Else > > End If > > Catch ex As Exception > strOS = "Error" > 'MessageBox.Show(ex.InnerException.ToString) > > End Try > ' System.Threading.Thread.Sleep(5000) > End Sub > Private Sub ResultOutput() > ComputerResultsFile.WriteLine(UCase(strResult)) > 'ComputerResultsFile.Close() > End Sub > > Private Function SystemAlive(ByVal Name As String, ByRef PingResult As > Boolean) As Boolean > > Dim pingClient As New Ping > Dim status As IPStatus > 'Dim PingResult As Boolean > PingResult = False > > Try > status = pingClient.Send(Name, 1000).Status > If status = IPStatus.Success Then > PingResult = True > 'StatusBar1.Text = Name & " Ping Successful" > 'MessageBox.Show("Machine is on we can now do whatever") > Else > StatusBar1.Text = Name & " Ping TimedOut" > PingResult = False > 'MessageBox.Show("Can't contact machine : " & > status.ToString) > End If > Catch ex As Exception > PingResult = False > 'MessageBox.Show(ex.InnerException.ToString) > StatusBar1.Text = Name & " Error" > End Try > SystemAlive = PingResult > > > > End Function > > The script writes the list of computer without issue. However something > breaks after that and I get the following error. > > The CLR has been unable to transition from COM context 0x1a0120 to COM > context 0x1a0290 for 60 seconds. > > Thanks for any help >
MS's Excruciating Update Cycles
Translation of CreateFile dll in dot net My computer seems to be to slow to run VS2005 XML into datagrid REPOST: preventing more than one user from working on the same record Calendar with custom tooltip over days with events Is it possible to use Field Names instead of Item(0) with Data Row using VB.Net 2005 ? Web Panel? How to compare time? Using Find method on a List(of type) Breaks the Reference |
|||||||||||||||||||||||