Click here to Skip to main content
15,885,159 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone

I have a VB2010 .Net program which maintains Supplier details. Each supplier has a certificate (PDF). The Supplier Maintenance program has a button which is intended to open a File dialog box, allow the user to select a PDF file and the program then stores the path and file name.

VB
Private Sub but_Certificate_Path_Click(sender As System.Object, e As System.EventArgs) Handles but_Certificate_Path.Click
    Dim ofd As New OpenFileDialog

    ofd.Filter = "PDF Files(*.pdf)|*.pdf|All files (*.*)|*.*"

    ofd.FilterIndex = 1
    ofd.InitialDirectory = "\\xxx\BEE"

    If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then  '<--CRASH OCCURS HERE
        txt_Bee_Certificate_Path.Text = ofd.FileName
    End If

End Sub


When the 'Path' button is clicked the program crashes with :
AccessViolationException
Attempted to read or write protected memory.
This is often an indication that other memory is corrupt.

I am not using the OpenFileDialog1 control.


The Call Stack info that I am able to find is :
SupplierMaintenance.exe!SupplierMaintenance.frm_Supplier_Maint.but_Certificate_Path_Click(Object sender, System.EventArgs e) Line 415 Basic
user32.dll!766462fa()
[Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]
user32.dll!76646d3a()
user32.dll!76646ce9()
ntdll.dll!76fd010a()
user32.dll!7664788a()
[External Code]
mscoreei.dll!6d0ef4f3()
KernelBase.dll!761c1e4b()
mscoree.dll!6de77efd()
mscoree.dll!6de77f16()
mscoree.dll!6de74de3()
kernel32.dll!760b336a()
ntdll.dll!76ff9f72()
ntdll.dll!76ff9f45()

Do I have a coding problem or a problem with user32.dll?

Does anyone know how I can resolve this - I am absolutely clueless.

Many thanks
Posted
Comments
Richard MacCutchan 4-Dec-13 6:48am    
Are you sure that initial directory path is valid?
Darrell de Wet 4-Dec-13 7:24am    
Yes. I just changed it to xxx for this post. xxx = File server name.
Richard MacCutchan 4-Dec-13 8:06am    
All I can suggest is that you step through the code with your debugger and try to find out what is happening.
Fredrik Bornander 4-Dec-13 8:33am    
Create a new WinForms application with a single button that has the payload of the above OnClick handler to verify that it is not an environment issue.
If that application does not crash then it's something that your application has done to it's memory before calling that method.

Are you PInvoking anything?
Are you using unsafe code?
Darrell de Wet 5-Dec-13 2:36am    
Hi Fredrik - thanks for your response.
I hope that I am not using any unsafe code - what would unsafe code be?
I am relatively new to .Net so I can do with all the assistance I can get

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900