|
-
Feb 11th, 2011, 05:53 PM
#1
Thread Starter
Lively Member
VS 2010 IDE crashes using this class
This class, along with a few others prominent in my projects, crashes the VS IDE:
Code:
Public Class IO
Public Shared Function OpenString(ByVal FilePath As String) As String
Try
Dim objReader As New System.IO.StreamReader(FilePath)
Dim ret As String = objReader.ReadToEnd
objReader.Close()
Return ret
Catch ex As Exception
Return Nothing
End Try
End Function
Public Shared Sub SaveString(ByVal FilePath As String, ByVal SourceString As String)
On Error Resume Next
FileIO.FileSystem.WriteAllText(FilePath, SourceString, False)
End Sub
Public Shared Function FolderExists(ByVal FolderPath As String) As Boolean
Dim f As New System.IO.DirectoryInfo(FolderPath)
Return f.Exists
End Function
Public Shared Sub LoadList(ByRef ListObject As Object, ByVal FilePath As String)
Dim r As System.IO.StreamReader
r = New System.IO.StreamReader(FilePath)
While (r.Peek() > -1)
ListObject.Items.Add(r.ReadLine)
End While
r.Close()
End Sub
Public Shared Sub SaveList(ByVal ListObject As Object, ByVal FilePath As String)
Dim w As System.IO.StreamWriter
Dim i As Integer
w = New System.IO.StreamWriter(FilePath)
For i = 0 To ListObject.Items.Count - 1
w.WriteLine(ListObject.Items.Item(i))
Next
w.Close()
End Sub
Public Shared Sub ListFiles(ByRef L As Object, ByVal folderpath As String, Optional ByVal extension As String = "*.dll")
Try
Dim DirInfo As New DirectoryInfo(folderpath)
Dim FileInfoArray() As FileInfo = DirInfo.GetFiles(extension)
Dim FileInfo As FileInfo
Dim FileCount As Integer = 0
For Each FileInfo In FileInfoArray
FileCount = FileCount + 1
L.Items.Add(FileInfo.Name)
Next
Catch ex As Exception
ErrMsg()
End Try
End Sub
End Class
What the hell is wrong? I've tried just about everything from compatibility mode to admin to a couple registry edits...I've even reinstalled and am seriously considering a reformat. It does the same on my friend's VS. Apparently it's LoadList that does it in this particular class, but as I said before, a couple of my modules/classes in various other projects also pose the same issue, even without LoadList.
Sorry if this is the wrong section.
-
Feb 11th, 2011, 05:57 PM
#2
Re: VS 2010 IDE crashes using this class
It's your class name... at least that's the first thing that jumped out at me. It maybe conflicting with the built-in IO namespace that's already part of the .NET Framework.
-tg
-
Feb 15th, 2011, 04:28 PM
#3
Thread Starter
Lively Member
Re: VS 2010 IDE crashes using this class
 Originally Posted by techgnome
It's your class name... at least that's the first thing that jumped out at me. It maybe conflicting with the built-in IO namespace that's already part of the .NET Framework.
-tg
A friend and I have actually resolved it, it's a pretty big bug in the IDE. Sometimes (note: not always) when trying to view a class with a direct-object as an argument in a method, the IDE crashes. So, in this specific class, I had to change the Object argument in the LoadList method to an IList object.
Thanks for replying, though
-
Feb 15th, 2011, 04:54 PM
#4
Re: VS 2010 IDE crashes using this class
"Sometimes (note: not always) when trying to view a class with a direct-object as an argument in a method, the IDE crashes." -- uuuuh... WHAT? I didn't follow... what do you mean "direct object"...
-tg
-
Feb 15th, 2011, 04:58 PM
#5
Re: VS 2010 IDE crashes using this class
FYI - I copied your code.... changing only two lines, I got it to compile just fine... so I'm not sure what you're doing that's causing the crash.
-tg
-
Feb 15th, 2011, 08:27 PM
#6
Re: VS 2010 IDE crashes using this class
 Originally Posted by techgnome
FYI - I copied your code.... changing only two lines, I got it to compile just fine... so I'm not sure what you're doing that's causing the crash.
-tg
Maybe you should tell us which two lines you changed in the original code?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Feb 15th, 2011, 10:12 PM
#7
Re: VS 2010 IDE crashes using this class
I imported the IO namespace... and commented out the call to the ErrMsg() function as it wasn't in the code. That's it.
Now, I said it compiled... didn't actually make any calls to it... since I'm not sure how it was being called or used...
-tg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|