|
-
Jul 28th, 2011, 04:05 PM
#1
Thread Starter
Frenzied Member
Error on users computer
Hi guys
I have someone who downloaded my program using click-once.
My program allows user to read a .txt file and then manipulate data
The user selects the file to open by goin gto File>Open on menu strip
I have a user who gets an error message upon clicking on File Open
It doesnt open up the OpenFileDialog
return ans unhandled exception
Method not found
System Windows.Forms OpenFileDialog get_SafeFileName
Anyone have an idea what i should be looking at I cant re-create it on my end
Thanks
-
Jul 28th, 2011, 04:25 PM
#2
Re: Error on users computer
What is their OS and what is yours? Also, can you post the code that is run when you click Open?
-
Jul 28th, 2011, 04:31 PM
#3
Thread Starter
Frenzied Member
Re: Error on users computer
I have developed it on XP service pack3 and they are on XP waiting to confirm there version and SP info
it appears the use of "SafeFileName" may be the issue with different version of 2.0 framework ?
vb Code:
Do
OpenFileDialog1.InitialDirectory = "C:\"
OpenFileDialog1.Filter = "Text Files (*.txt)|*.txt|CSV Files (*.csv)|*.csv"
Me.OpenFileDialog1.FileName = ""
If Me.OpenFileDialog1.ShowDialog() <> Windows.Forms.DialogResult.OK Then Exit Sub
Me.ToolStripStatusLabel4.Text = Me.OpenFileDialog1.SafeFileName
With OpenFileDialog1
Dim folderName As String
folderName = .FileName.Substring(0, .FileName.LastIndexOf("\"))
Me.ToolStripStatusLabel3.Text = folderName
End With
Thanks
-
Jul 28th, 2011, 04:54 PM
#4
Re: Error on users computer
The SafeFileName property is only supported in the 3.0 framework and higher. You can confirm that by reviewing the documentation here. This means (since you are targetting the .NET 2.0 framework) that you can't use it. I believe there is a problem with there being two different versions of the v2.0 System.Windows.Forms library.
You can use, and should use this to get your file name (the SafeFileName property calls this internally anyway):
Code:
Dim safeFileName As String = IO.Path.GetFileName(fullPath)
-
Jul 28th, 2011, 06:59 PM
#5
Thread Starter
Frenzied Member
Re: Error on users computer
-
Aug 4th, 2011, 12:07 AM
#6
Thread Starter
Frenzied Member
Re: Error on users computer
Ok so I changed the code as suggested by ForumAccount and the user got it working. Now they just emailed me and said they get the same message when
"using windows7 running via parallels on a macbook pro."
I have no idea what that even means , can someone tell me what might be happening?
Thanks
-
Aug 4th, 2011, 08:54 AM
#7
Re: Error on users computer
What is the error, stack trace and line of code for this error?
-
Aug 4th, 2011, 11:57 AM
#8
Thread Starter
Frenzied Member
Re: Error on users computer
Unhandled exception has occured in your application. If you click continue........etc
Method not found
System Windows.Forms OpenFileDialog get_SafeFileName
-
Aug 4th, 2011, 11:58 AM
#9
Re: Error on users computer
You are still calling that property somewhere.
-
Aug 4th, 2011, 01:06 PM
#10
Thread Starter
Frenzied Member
Re: Error on users computer
Thats what i thought, But I dont see it anywhere. I ran Find and Replace and it doesnt come up??
any other ideas?
-
Aug 4th, 2011, 01:09 PM
#11
Re: Error on users computer
Please post all of the error details. The whole stack trace. Please also post the actual code that is failing.
-
Aug 4th, 2011, 01:22 PM
#12
Thread Starter
Frenzied Member
Re: Error on users computer
I dont have error details the user is getting the errror. The error is actually the error message from the below code and not the >SafeFileName, I beleive the user was mistaken. I walked through this with another user on Windows & who gets this message. "Invalid or Corrupt Data File.....etc."
Windows 7 to test it on
This is the block of code in which the recieve the error.
vb Code:
Do
OpenFileDialog1.InitialDirectory = "C:\"
OpenFileDialog1.Filter = "Text Files (*.txt)|*.txt|CSV Files (*.csv)|*.csv"
Me.OpenFileDialog1.FileName = ""
If Me.OpenFileDialog1.ShowDialog() <> Windows.Forms.DialogResult.OK Then Exit Sub
Dim safeFileName As String = IO.Path.GetFileName(Me.OpenFileDialog1.FileName)
Me.ToolStripStatusLabelFileName.Text = Me.OpenFileDialog1.FileName
With OpenFileDialog1
Dim folderName As String
folderName = .FileName.Substring(0, .FileName.LastIndexOf("\"))
Me.ToolStripStatusLabel3.Text = folderName
End With
Me.Refresh()
Me.ToolStripProgressBar1.Visible = True
Try
Me.ToolStripProgressBar1.Value = 10
If safeFileName.EndsWith(".txt") Then
createschema()
End If
Me.ToolStripProgressBar1.Value = 20
con.Dispose()
ClearData()
BuildConnectionString()
SetConnString()
ReadColNames()
Me.ToolStripProgressBar1.Value = 30
CreateDataSets()
LoadSubjectValues()
If Subj_Val() = True Then
Else : Exit Sub
End If
LoadForm2()
Value_Trends()
Exit Do
Catch
MsgBox("Invalid or Corrupt Data File Type" & " " & "Select a Different Data File" & vbCrLf & "or Check Status Codes in Setup Menu", MsgBoxStyle.Critical, "Data Error")
Exit Sub
End Try
Loop
End If
This is used to create the schema file:
vb Code:
Private Sub createschema()
Dim safeFileName As String = IO.Path.GetFileName(Me.OpenFileDialog1.FileName)
Dim fs As New FileStream("Schema.ini", FileMode.Create, FileAccess.Write)
Dim writer As New StreamWriter(fs)
Dim fn As String = safeFileName
writer.WriteLine("[" & fn & "]")
writer.WriteLine("Format = TabDelimited")
writer.WriteLine("MaxScanRows = 0")
writer.Close()
End Sub
This is used for connectionn string:
vb Code:
Private Sub BuildConnectionString()
builder("Provider") = "Microsoft.Jet.OLEDB.4.0"
builder("Data Source") = IO.Path.GetDirectoryName(Me.OpenFileDialog1.FileName)
builder("extended properties") = "text;HDR=Yes;FMT=Delimited"
End Sub
And thi sis used to create datatables
vb Code:
Public Sub CreateDataSets()
Dim safeFileName As String = IO.Path.GetFileName(Me.OpenFileDialog1.FileName)
Dim StatusClosed As String
StatusClosed = Form11.Closed_Code.Text
Dim DateSold As String
DateSold = Form10.DateSold_txt.Text
Dim SubjId As String
SubjId = Form10.add_Num_txt.Text
Dim Status As String
Status = Form10.status_txt.Text
Try
Dim sql As String = String.Format("Select * From {0} WHERE " & Status & " <> @Status AND [" & SubjId & "] <> @SubjAdd ", safeFileName)
Dim comm As New OleDb.OleDbCommand(sql, con)
comm.Parameters.AddWithValue("@Status", Form11.Closed_Code.Text)
comm.Parameters.AddWithValue("@SubjAdd", 111111)
Dim dalist As New OleDbDataAdapter(comm)
dalist.Fill(dtlist)
AddCol()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Try
Dim comm1 As New OleDbCommand("SELECT * FROM " & safeFileName & " Where " & Status & " = '" & StatusClosed & "'", con)
Dim dasold As New OleDbDataAdapter(comm1)
dasold.Fill(dtsold)
AddColsold()
Catch ex As Exception
MsgBox(ex.Message)
MsgBox("All Property's with a Sold Status Should have a Date Sold" & vbCrLf & "Please Check Your Data File" & vbCrLf & "One or More of Your Records may NOT have a Sold Date")
End Try
Try
Dim comm2 As New OleDbCommand("Select * From " & safeFileName & " Where instr([" & SubjId & "], '111111' )", con)
Dim subject As New OleDbDataAdapter(comm2)
subject.Fill(dtsubj)
Catch ex As Exception
MsgBox(ex.Message)
End Try
Me.BindingSource1.DataSource = dtlist
Me.BindingSource2.DataSource = dtlist
Me.BindingSource3.DataSource = dtlist
Me.BindingSource4.DataSource = dtsold
Me.BindingSource4.Sort = "NewDateSold Desc"
Me.BindingSource5.DataSource = dtsold
Me.BindingSource6.DataSource = dtsold
Me.BindingSource7.DataSource = dtsubj
con.Close()
End Sub
-
Aug 5th, 2011, 11:03 AM
#13
Thread Starter
Frenzied Member
Re: Error on users computer
Ok it looks like I am going to need to get a windows 7 machine going so I can test this on my end
Should I get a 64 bit machine? Or am i ok with just getting 32 bit version of windows 7 and upgrading one of my exisiting machines?
-
Aug 5th, 2011, 11:13 AM
#14
Re: Error on users computer
Code:
Catch
MsgBox("Invalid or Corrupt Data File Type" & " " & "Select a Different Data File" & vbCrLf & "or Check Status Codes in Setup Menu", MsgBoxStyle.Critical, "Data Error")
Exit Sub
End Try
You are completely ignoring the actual problem and making up your own reason for failure. Tell the user what the failure is!!
Code:
Catch Ex As Exception
MsgBox("Invalid or Corrupt Data File Type" & " " & "Select a Different Data File" & vbCrLf & "or Check Status Codes in Setup Menu" & vbCrLf & Ex.Message, MsgBoxStyle.Critical, "Data Error")
Exit Sub
End Try
Last edited by Grimfort; Aug 5th, 2011 at 11:17 AM.
-
Aug 5th, 2011, 11:22 AM
#15
Thread Starter
Frenzied Member
Re: Error on users computer
 Originally Posted by Grimfort
Code:
Catch
MsgBox("Invalid or Corrupt Data File Type" & " " & "Select a Different Data File" & vbCrLf & "or Check Status Codes in Setup Menu", MsgBoxStyle.Critical, "Data Error")
Exit Sub
End Try
You are completely ignoring the actual problem and making up your own reason for failure. Tell the user what the failure is!!
Code:
Catch Ex As Exception
MsgBox("Invalid or Corrupt Data File Type" & " " & "Select a Different Data File" & vbCrLf & "or Check Status Codes in Setup Menu" & vbCrLf & Ex.Message, MsgBoxStyle.Critical, "Data Error")
Exit Sub
End Try
Huh ?????
I dont know what the problem is. The file is fine, it opens on XP. There is something in my code that is not working on Windows 7
Oh Ok I re-Read you post and understand what you are saying, I am placing my own error message and not getting the actual error .
I still would have the problem of having to re-deploy and wait for user to try it again. Doenst seem an effective way of trouble shooting. Thats why i was just going to get a windows 7 machine especially since more and more people seem to moving to that?
Thanks
Last edited by billboy; Aug 5th, 2011 at 11:32 AM.
-
Aug 5th, 2011, 11:53 AM
#16
Re: Error on users computer
Getting it to happen again is your problem . You may find that the issue is actually a security setting on that users box, or a corrupt file, or anything else environment related that you will not know how to replicate. Getting a test box for each OS is advisable, but sometimes resources are limited.
-
Aug 5th, 2011, 12:08 PM
#17
Thread Starter
Frenzied Member
Re: Error on users computer
Thanks,
The user is using the same file on an XP machine and working fine. I have 2 users with same problem.
So I am pretty sure it has something to do with Windows 7, its a relatively simple program that reads a txt file. After googling I read that I should compile targeting x86. Since I am using MS Jet 4.0
Resources are VERY limited over here thats why i was looking for some advice from people with more experience then me as to which way to go. I am a bit confused by the wqhole 64/32 bit thing but reading about.
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
|