Results 1 to 17 of 17

Thread: Error on users computer

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    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

  2. #2
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    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?

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    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:
    1. Do
    2.                 OpenFileDialog1.InitialDirectory = "C:\"
    3.  
    4.                 OpenFileDialog1.Filter = "Text Files (*.txt)|*.txt|CSV Files (*.csv)|*.csv"
    5.                 Me.OpenFileDialog1.FileName = ""
    6.  
    7.                 If Me.OpenFileDialog1.ShowDialog() <> Windows.Forms.DialogResult.OK Then Exit Sub
    8.                 Me.ToolStripStatusLabel4.Text = Me.OpenFileDialog1.SafeFileName
    9.  
    10.                 With OpenFileDialog1
    11.                     Dim folderName As String
    12.                     folderName = .FileName.Substring(0, .FileName.LastIndexOf("\"))
    13.                     Me.ToolStripStatusLabel3.Text = folderName
    14.                 End With

    Thanks

  4. #4
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    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)

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    Re: Error on users computer

    Thanks

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    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

  7. #7
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Error on users computer

    What is the error, stack trace and line of code for this error?

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    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

  9. #9
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Error on users computer

    You are still calling that property somewhere.

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    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?

  11. #11
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    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.

  12. #12

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    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:
    1. Do
    2.                 OpenFileDialog1.InitialDirectory = "C:\"
    3.                 OpenFileDialog1.Filter = "Text Files (*.txt)|*.txt|CSV Files (*.csv)|*.csv"
    4.                 Me.OpenFileDialog1.FileName = ""
    5.  
    6.                 If Me.OpenFileDialog1.ShowDialog() <> Windows.Forms.DialogResult.OK Then Exit Sub
    7.                 Dim safeFileName As String = IO.Path.GetFileName(Me.OpenFileDialog1.FileName)
    8.  
    9.                 Me.ToolStripStatusLabelFileName.Text = Me.OpenFileDialog1.FileName
    10.  
    11.                 With OpenFileDialog1
    12.                     Dim folderName As String
    13.                     folderName = .FileName.Substring(0, .FileName.LastIndexOf("\"))
    14.                     Me.ToolStripStatusLabel3.Text = folderName
    15.                 End With
    16.                 Me.Refresh()
    17.                 Me.ToolStripProgressBar1.Visible = True
    18.                 Try
    19.                     Me.ToolStripProgressBar1.Value = 10
    20.                     If safeFileName.EndsWith(".txt") Then
    21.                         createschema()
    22.                     End If
    23.                     Me.ToolStripProgressBar1.Value = 20
    24.                     con.Dispose()
    25.                     ClearData()
    26.                     BuildConnectionString()
    27.                     SetConnString()
    28.                     ReadColNames()
    29.                     Me.ToolStripProgressBar1.Value = 30
    30.                     CreateDataSets()
    31.                     LoadSubjectValues()
    32.                     If Subj_Val() = True Then
    33.                     Else : Exit Sub
    34.                     End If
    35.                     LoadForm2()
    36.                     Value_Trends()
    37.                     Exit Do
    38.                 Catch
    39.                     MsgBox("Invalid or Corrupt Data File Type" & "   " & "Select a Different Data File" & vbCrLf & "or Check Status Codes in Setup Menu", MsgBoxStyle.Critical, "Data Error")
    40.                     Exit Sub
    41.                 End Try
    42.             Loop
    43.         End If


    This is used to create the schema file:

    vb Code:
    1. Private Sub createschema()
    2.         Dim safeFileName As String = IO.Path.GetFileName(Me.OpenFileDialog1.FileName)
    3.         Dim fs As New FileStream("Schema.ini", FileMode.Create, FileAccess.Write)
    4.         Dim writer As New StreamWriter(fs)
    5.         Dim fn As String = safeFileName
    6.         writer.WriteLine("[" & fn & "]")
    7.         writer.WriteLine("Format = TabDelimited")
    8.         writer.WriteLine("MaxScanRows = 0")
    9.         writer.Close()
    10.  
    11.     End Sub

    This is used for connectionn string:

    vb Code:
    1. Private Sub BuildConnectionString()
    2.         builder("Provider") = "Microsoft.Jet.OLEDB.4.0"
    3.         builder("Data Source") = IO.Path.GetDirectoryName(Me.OpenFileDialog1.FileName)
    4.         builder("extended properties") = "text;HDR=Yes;FMT=Delimited"
    5.     End Sub

    And thi sis used to create datatables

    vb Code:
    1. Public Sub CreateDataSets()
    2.         Dim safeFileName As String = IO.Path.GetFileName(Me.OpenFileDialog1.FileName)
    3.         Dim StatusClosed As String
    4.         StatusClosed = Form11.Closed_Code.Text
    5.         Dim DateSold As String
    6.         DateSold = Form10.DateSold_txt.Text
    7.         Dim SubjId As String
    8.         SubjId = Form10.add_Num_txt.Text
    9.         Dim Status As String
    10.         Status = Form10.status_txt.Text
    11.         Try
    12.             Dim sql As String = String.Format("Select * From {0} WHERE " & Status & " <> @Status AND [" & SubjId & "] <> @SubjAdd ", safeFileName)
    13.             Dim comm As New OleDb.OleDbCommand(sql, con)
    14.             comm.Parameters.AddWithValue("@Status", Form11.Closed_Code.Text)
    15.             comm.Parameters.AddWithValue("@SubjAdd", 111111)
    16.             Dim dalist As New OleDbDataAdapter(comm)
    17.             dalist.Fill(dtlist)
    18.             AddCol()
    19.         Catch ex As Exception
    20.             MsgBox(ex.Message)
    21.         End Try
    22.         Try
    23.             Dim comm1 As New OleDbCommand("SELECT *  FROM " & safeFileName & "  Where " & Status & " = '" & StatusClosed & "'", con)
    24.             Dim dasold As New OleDbDataAdapter(comm1)
    25.             dasold.Fill(dtsold)
    26.             AddColsold()
    27.         Catch ex As Exception
    28.             MsgBox(ex.Message)
    29.             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")
    30.         End Try
    31.  
    32.         Try
    33.             Dim comm2 As New OleDbCommand("Select * From " & safeFileName & " Where instr([" & SubjId & "], '111111' )", con)
    34.             Dim subject As New OleDbDataAdapter(comm2)
    35.             subject.Fill(dtsubj)
    36.         Catch ex As Exception
    37.             MsgBox(ex.Message)
    38.         End Try
    39.  
    40.         Me.BindingSource1.DataSource = dtlist
    41.         Me.BindingSource2.DataSource = dtlist
    42.         Me.BindingSource3.DataSource = dtlist
    43.         Me.BindingSource4.DataSource = dtsold
    44.         Me.BindingSource4.Sort = "NewDateSold Desc"
    45.         Me.BindingSource5.DataSource = dtsold
    46.         Me.BindingSource6.DataSource = dtsold
    47.         Me.BindingSource7.DataSource = dtsubj
    48.         con.Close()
    49.     End Sub

  13. #13

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    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?

  14. #14
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    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.

  15. #15

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    Re: Error on users computer

    Quote Originally Posted by Grimfort View Post
    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.

  16. #16
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    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.

  17. #17

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2009
    Location
    Los Angeles
    Posts
    1,335

    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
  •  



Click Here to Expand Forum to Full Width