تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
AccessViolationException was unhandled error
#1
,Hi everyone

:I'm facing an issue in my project every time that I'm trying to use "openfiledialog", and you can see the issue below
[ATTACH=CONFIG]1218[/ATTACH]

:And I have the following
.I had "Login Form", and I deleted it

.Changed the startup form to the MDIParent

!Debug the project and it's worked just fine

:The "Login Form" is
[ATTACH=CONFIG]1219[/ATTACH]

:And the code of the "Login Form" is
كود :
Imports System.Data.OleDb
Public Class LoginFrm

    Private Sub LoginFrm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        If UsersCount() = True Then
            MsgBox("There is no user in your system, you will be redirected to another form to add new user.", MsgBoxStyle.Information, "Login")
            AddUserFrm.MdiParent = MainFrmvb
            AddUserFrm.Show()
            'Me.Hide()
            Me.Close()
            Exit Sub
        End If
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        If Me.TextBox1.Text = "" Then
            MsgBox("You should enter the user name", vbOKOnly, "Login")
            Exit Sub
        ElseIf Me.TextBox2.Text = "" Then
            MsgBox("You should enter the password", vbOKOnly, "Login")
            Exit Sub
        ElseIf Me.TextBox1.Text = "Administrator" AndAlso Me.TextBox2.Text = "Administrator" Then ' this code I should remove it from here
            AfterLogin.MdiParent = MainFrmvb
            AfterLogin.Show()
            'Me.Hide()
            Me.Close()
        Else
            If UserLoggedIn() = True Then
                MsgBox("Wrong username or password", vbCritical, "Login")
            Else
                'checkpermissions()
                MsgBox("You logged in successfully", vbInformation, "Login")
                AfterLogin.Label1.Text = test()
                AfterLogin.MdiParent = MainFrmvb
                AfterLogin.Show()
                'Me.Hide()
                Me.Close()
            End If
        End If
    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Application.Exit()
    End Sub
    Function UsersCount()
        ' get the password from the database
        Dim DA As New ERPDataSetTableAdapters.User_Tbl_localTableAdapter
        Dim TB = DA.User_Count
        If TB = 0 Then
            Return True
        Else
            Return False
        End If
    End Function
    Function UserLoggedIn()
        ' get the password from the database
        Dim DA As New ERPDataSetTableAdapters.User_Tbl_localTableAdapter
        Dim TB = DA.GetDataByUserNamePass(Trim(Me.TextBox1.Text), Trim(Me.TextBox2.Text))
        If TB.Rows.Count = 0 Then
            Return True
        Else
            Return False
        End If
    End Function
    Function test()
        Dim DA As New ERPDataSetTableAdapters.User_Tbl_localTableAdapter
        Dim TBS = DA.GetDataByUserNamePass(Trim(Me.TextBox1.Text), Trim(Me.TextBox2.Text))
        Return TBS.Rows(0).Item(1)
    End Function
End Class



:I searched all the code, and I did the following
كود :
Private Sub LoginFrm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'If UsersCount() = True Then
        MsgBox("There is no user in your system, you will be redirected to another form to add new user.", MsgBoxStyle.Information, "Login")
        AddUserFrm.MdiParent = MainFrmvb
        AddUserFrm.Show()
        Me.Hide()
        'Me.Close()
        'Exit Sub
        'End If
End Sub

!If you noticed that I canceled the calling of the function "UsersCount()" and everything works fine

.I don't know what is the problem in that function

?Do you have any suggestion for me

.I'll appreciate it

.Best


الملفات المرفقة صورة/صور
       
الرد }}}
تم الشكر بواسطة:
#2
try change your code to

PHP كود :
if openfiledialog.showdialog=dialogresulut.ok then
'your code here
end if 
i couldnot understand your code here
are you trying to get count of recods inside the table
?
PHP كود :
Function UsersCount()
        
' get the password from the database
        Dim DA As New ERPDataSetTableAdapters.User_Tbl_localTableAdapter
        Dim TB = DA.User_Count
        If TB = 0 Then
            Return True
        Else
            Return False
        End If
    End Function 
kindly inform me about objects used in this function

best regards
الرد }}}
تم الشكر بواسطة:
#3
,Hi bro
.Thanks for replying me
:The following code is about a query in the Dataset that counts the users in the Users_Table


()Function UsersCount
get the password from the database
Dim DA
As New ERPDataSetTableAdapters.User_Tbl_localTableAdapter
Dim TB
= DA.User_Count
If TB = 0 Then
Return True
Else
Return
False
End
If
End Function


The problem is not in the (OpenFileDialog), it is in calling of these two (Functions -UsersCount- and -UserLoggedIn-) as I think but I'm not sure.

And the Function UserLoggedIn is to check if the user entered the correct username and password that were stored in the Users_Table.

I hope you got all the information that could help you to understand my issue.

I'll appreciate your help.
Best.
الرد }}}
تم الشكر بواسطة:
#4

,Hi hoob computer

"Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt”

: This issue shouldn't happen in managed code
You can try setting Visual Studio Debugger to bypass this exception

"Tools menu ->Options -> Debugging -> General -> Uncheck this option "Suppress JIT optimization on module load


I hope this will be helpful to your issue.

Best regards,

الرد }}}
تم الشكر بواسطة:
#5
.Hi Abdullah, Thanks for your reply
.I did what you said, but the issue still appears

?I think that issue is happening because I'm calling two queries from one table (Users_Table) and one TableAdapter, don't you think that

?So, what is the solution for that issue
الرد }}}
تم الشكر بواسطة:
#6
check the attached file it may help you to solve your issue


الملفات المرفقة
.rar   TestProject.rar (الحجم : 153.26 ك ب / التحميلات : 40)
الرد }}}
تم الشكر بواسطة:
#7
.Hi amgadtamer, thanks for your reply
:I used the following code

PHP كود :
Dim da As New ERPDataSetTableAdapters.User_Tbl_localTableAdapter
        Dim counter 
As Integer
        
If da.GetDataByUserNamePass(Trim(LoginFrm.TextBox1.Text), Trim(LoginFrm.TextBox2.Text)).HasErrors Then
            counter 
0
        
Else
            
counter CInt(da.GetDataByUserNamePass(Trim(LoginFrm.TextBox1.Text), Trim(LoginFrm.TextBox2.Text)).Rows.Count)
        
End If
        If 
counter 0 Then
            
Return False
        
Else
            Return 
True
        End 
If
    
End Function

    Public Function 
UsersCount()
        
Dim da As New ERPDataSetTableAdapters.User_Tbl_localTableAdapter '.USERSTBTableAdapter
        Dim counter As Integer
        If da.User_Count.HasValue Then
            counter = CInt(da.User_Count)
        Else
            counter = 0
        End If
        If counter <> 0 Then
            Return False
        Else
            Return True
        End If
    End Function 
.but the issue still appears
?what should I do
الرد }}}
تم الشكر بواسطة:
#8
. I attached the project to let you see the issue
.when I click on Open File or on the Done (Button1) in the AfterLogin.Frm form, I got the issue too

?So, what do you suggest


الملفات المرفقة
.zip   HR Management System - Copy.zip (الحجم : 3.18 م ب / التحميلات : 41)
الرد }}}
تم الشكر بواسطة:
#9
your project run on my pc without any errors
:confused:
الرد }}}
تم الشكر بواسطة:
#10
?Really
?Why isn't it run on my computer without errors
?Did you try to run the OpenFileDialog

.Before I called the UserLoggedIn, it was working fine
.I tried to remove that function and create another one, but nothing happened and the issue still appears

.I've even created a new project and put everything in it, but the same issue appeared again

.I have another projects, they run fine on my computer

?So, what do you suggest to me
الرد }}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  سؤالي عن a generic error occurred in gdi+ ahmed_elwerfalli 3 975 01-02-22, 03:40 PM
آخر رد: ahmed_elwerfalli
  Error In GridControl DevExpress yazanahmed 1 1,191 13-12-20, 10:49 PM
آخر رد: ابو ليلى
  [سؤال] Parse error: syntax error, unexpected '{' Sorax 4 1,898 15-02-20, 10:52 PM
آخر رد: محمد كريّم
  [سؤال] Error Syntax Insert Into" djelloul 11 4,644 28-12-19, 04:20 PM
آخر رد: مصطفى حفناوى
  حل مشكلة A generic error occurred in GDI+. samira20 2 1,946 17-12-19, 03:20 PM
آخر رد: asemshahen5
  Error creating window handle اسامه الهرماوي 3 3,748 09-10-19, 12:57 AM
آخر رد: اسامه الهرماوي
Rainbow (تم الحل )احتاج مساعدة حول خطأ system.accessviolationexception was unhandled dametucorazon 5 3,001 22-04-19, 12:47 AM
آخر رد: elgokr
  [سؤال] احتاج مساعدة يظهر لدى خطأ ExecutionengineException was unhandled dametucorazon 0 1,029 21-03-19, 09:09 AM
آخر رد: dametucorazon
  طريقة تكرار الامر تلقائيا | حل مشكلة script error في webbrowser عند فتح صفحة ما soloxocf1 6 3,223 18-03-19, 09:16 AM
آخر رد: 5000
  ما هو حل مشكلة هذا ال Error The connection was not closed. The connection's current mostafa nada 3 3,144 12-02-19, 06:58 PM
آخر رد: asemshahen5

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم