2012-09-20 44 views
0

今天早些時候,我問了這個問題debugger in vb.net skips line,但我剛剛發現了一些關於我正在開發的項目的奇怪的東西(或者對vb.net來說可能是正常的)。 我正在編輯vb文件,添加一些方法。 調試原始文件工作正常,我可以進入代碼並通過每行,逐行,沒有任何問題。 現在,當我加了一些方法調試工作確實很奇怪,檢查這兩個截圖:vb.net調試器跳過調試線

  1. 網站未啓動 - >在地方所有斷點:http://gyazo.com/1077b7efbdb2b37174d5960cdff0bda5.png?1348160907

  2. 網站開始 - >斷點在第2行缺少:http://gyazo.com/3051303d6eb27af9ea13bd6e72b81a83.png?1348161507

而且,當我加入了方法的文件,現在調試不走一行行,但在一號線的示例步驟,然後當我點擊f10,它進一步下面20行,它不會到代碼中的下一行。 我第一次編輯vb.net代碼,我一直在使用c#,並且我不知道編輯文件後是否需要修改某些內容,以便調試器能正常工作。

原始代碼:

Public Class Login 
    Inherits System.Web.UI.Page 

    Private m_objFranchiseInfo As New clsFranchiseInfo 

    Private Sub Login_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init 
     Dim sEmail As String = Request.QueryString("email") 
     Dim sPswd As String = Request.QueryString("password") 



     If (Not String.IsNullOrWhiteSpace(sEmail) And Not String.IsNullOrWhiteSpace(sPswd)) Then 

      If (sEmail.ToLower = "[email protected]") Then 
       FormsAuthentication.SetAuthCookie(sEmail, False) 
       Session("UserName") = sEmail 
       Session("Password") = sPswd 
      Else 

       Dim objService As New clsPropertyware 
       With objService 

        .UserName = sEmail 
        .Password = sPswd 
        .Initialize() 

        If .TestConnection = True Then 
         FormsAuthentication.SetAuthCookie(sEmail, False) 
         Session("UserName") = sEmail.ToLower 
         Session("Password") = sPswd 
         Session("OrgID") = .GetOrgID 


        Else 
         FormsAuthentication.SetAuthCookie("", True) 
         Session("UserName") = String.Empty 
         Session("Password") = String.Empty 
         Session("OrgID") = String.Empty 
        End If 

       End With 


      End If 
     Else 
      FormsAuthentication.SignOut() 
      Session("UserName") = String.Empty 
      Session("Password") = String.Empty 
      Session("OrgID") = String.Empty 
     End If 
    End Sub 



    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 

     Dim sEmail As String = Request.QueryString("email") 
     Dim sPswd As String = Request.QueryString("password") 

     If (Not String.IsNullOrWhiteSpace(sEmail) And Not String.IsNullOrWhiteSpace(sPswd)) Then 

      If (sEmail.ToLower = "[email protected]") Then 
       FormsAuthentication.SetAuthCookie(sEmail, False) 
       Session("UserName") = sEmail 
       Session("Password") = sPswd 
      Else 

       Dim objService As New clsPropertyware 
       With objService 

        .UserName = sEmail 
        .Password = sPswd 
        .Initialize() 

        If .TestConnection = True Then 
         FormsAuthentication.SetAuthCookie(sEmail, False) 
         Session("UserName") = sEmail.ToLower 
         Session("Password") = sPswd 
         Session("OrgID") = .GetOrgID 
         Response.Redirect("~/default.aspx") 
        Else 
         FormsAuthentication.SetAuthCookie("", True) 
         Session("UserName") = String.Empty 
         Session("Password") = String.Empty 
         Session("OrgID") = String.Empty 
        End If 

       End With 


      End If 
     Else 
      FormsAuthentication.SignOut() 
      Session("UserName") = String.Empty 
      Session("Password") = String.Empty 
      Session("OrgID") = String.Empty 
     End If 
    End Sub 



    Private Sub LoginUser_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles LoginUser.Authenticate 

     Dim szUserName As String = CType(LoginUser.FindControl("UserName"), TextBox).Text().Trim() 
     Dim szPassword As String = CType(LoginUser.FindControl("Password"), TextBox).Text().Trim() 

     If (szUserName.ToLower = "[email protected]") Then 
      e.Authenticated = True 
      Session("UserName") = szUserName 
      Session("Password") = szPassword 
     Else 

      Dim objService As New clsPropertyware 
      With objService 

       .UserName = szUserName 
       .Password = szPassword 
       .Initialize() 

       If .TestConnection = True Then 
        e.Authenticated = True 
        Session("UserName") = szUserName.ToLower 
        Session("Password") = szPassword 
        Session("OrgID") = .GetOrgID 
       Else 
        e.Authenticated = False 
        Session("UserName") = String.Empty 
        Session("Password") = String.Empty 
        Session("OrgID") = String.Empty 
       End If 

      End With 
     End If 

    End Sub 


    Private Sub LoginUser_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles LoginUser.LoggedIn 

     If (Session("UserName") = "[email protected]") Then 
      Response.Redirect("~/UploadValues.aspx") 
     Else 

      m_objFranchiseInfo.Clear() 
      If (m_objFranchiseInfo.Load(Session("UserName")) = True) Then 
       Session("FranchiseAgent") = m_objFranchiseInfo.szAgent 
       Session("FranchiseAgent2") = m_objFranchiseInfo.szAgent2 
       Session("FranchiseAddress") = m_objFranchiseInfo.szAddress 
       Session("FranchiseCity") = m_objFranchiseInfo.szCity 
       Session("FranchiseState") = m_objFranchiseInfo.szState 
       Session("FranchiseZip") = m_objFranchiseInfo.szZip 
       Session("FranchisePhone") = m_objFranchiseInfo.szPhone 
       Session("FranchiseFax") = m_objFranchiseInfo.szFax 
       Session("FranchiseEmail") = m_objFranchiseInfo.szEmail 
      Else 
       Response.Redirect("~\FranchiseInfo.aspx") 
      End If 
     End If 

    End Sub 
End Class 

修改後的代碼:

Imports System.Security.Cryptography 

Public Class Login 
    Inherits System.Web.UI.Page 

    Private m_objFranchiseInfo As New clsFranchiseInfo 

    Private Sub Login_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init 
     Dim sEmail As String = Request.QueryString("email") 
     Dim sPswd As String = Request.QueryString("password") 



     If (Not String.IsNullOrWhiteSpace(sEmail) And Not String.IsNullOrWhiteSpace(sPswd)) Then 

      If (sEmail.ToLower = "[email protected]") Then 
       FormsAuthentication.SetAuthCookie(sEmail, False) 
       Session("UserName") = sEmail 
       Session("Password") = sPswd 
      Else 

       Dim objService As New clsPropertyware 
       With objService 

        .UserName = sEmail 
        .Password = sPswd 
        .Initialize() 

        If .TestConnection = True Then 
         FormsAuthentication.SetAuthCookie(sEmail, False) 
         Session("UserName") = sEmail.ToLower 
         Session("Password") = sPswd 
         Session("OrgID") = .GetOrgID 


        Else 
         FormsAuthentication.SetAuthCookie("", True) 
         Session("UserName") = String.Empty 
         Session("Password") = String.Empty 
         Session("OrgID") = String.Empty 
        End If 

       End With 


      End If 
     Else 
      FormsAuthentication.SignOut() 
      Session("UserName") = String.Empty 
      Session("Password") = String.Empty 
      Session("OrgID") = String.Empty 
     End If 
    End Sub 



    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 

     Dim encryptedEmail As String = "[email protected]" 
     Dim decryptEmail As String = DecryptData("[email protected]") 
     Dim encrpytedPassword As String = "password" 




     Dim sEmail As String = Request.QueryString("email") 
     Dim sPswd As String = Request.QueryString("password") 

     If (Not String.IsNullOrWhiteSpace(sEmail) And Not String.IsNullOrWhiteSpace(sPswd)) Then 

      If (sEmail.ToLower = "[email protected]") Then 
       FormsAuthentication.SetAuthCookie(sEmail, False) 
       Session("UserName") = sEmail 
       Session("Password") = sPswd 
      Else 

       Dim objService As New clsPropertyware 
       With objService 

        .UserName = sEmail 
        .Password = sPswd 
        .Initialize() 

        If .TestConnection = True Then 
         FormsAuthentication.SetAuthCookie(sEmail, False) 
         Session("UserName") = sEmail.ToLower 
         Session("Password") = sPswd 
         Session("OrgID") = .GetOrgID 
         Response.Redirect("~/default.aspx") 
        Else 
         FormsAuthentication.SetAuthCookie("", True) 
         Session("UserName") = String.Empty 
         Session("Password") = String.Empty 
         Session("OrgID") = String.Empty 
        End If 

       End With 


      End If 
     Else 
      FormsAuthentication.SignOut() 
      Session("UserName") = String.Empty 
      Session("Password") = String.Empty 
      Session("OrgID") = String.Empty 
     End If 
    End Sub 



    Private Sub LoginUser_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles LoginUser.Authenticate 

     Dim szUserName As String = CType(LoginUser.FindControl("UserName"), TextBox).Text().Trim() 
     Dim szPassword As String = CType(LoginUser.FindControl("Password"), TextBox).Text().Trim() 

     If (szUserName.ToLower = "[email protected]") Then 
      e.Authenticated = True 
      Session("UserName") = szUserName 
      Session("Password") = szPassword 
     Else 

      Dim objService As New clsPropertyware 
      With objService 

       .UserName = szUserName 
       .Password = szPassword 
       .Initialize() 

       If .TestConnection = True Then 
        e.Authenticated = True 
        Session("UserName") = szUserName.ToLower 
        Session("Password") = szPassword 
        Session("OrgID") = .GetOrgID 
       Else 
        e.Authenticated = False 
        Session("UserName") = String.Empty 
        Session("Password") = String.Empty 
        Session("OrgID") = String.Empty 
       End If 

      End With 
     End If 

    End Sub 


    Private Sub LoginUser_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles LoginUser.LoggedIn 

     If (Session("UserName") = "[email protected]") Then 
      Response.Redirect("~/UploadValues.aspx") 
     Else 

      m_objFranchiseInfo.Clear() 
      If (m_objFranchiseInfo.Load(Session("UserName")) = True) Then 
       Session("FranchiseAgent") = m_objFranchiseInfo.szAgent 
       Session("FranchiseAgent2") = m_objFranchiseInfo.szAgent2 
       Session("FranchiseAddress") = m_objFranchiseInfo.szAddress 
       Session("FranchiseCity") = m_objFranchiseInfo.szCity 
       Session("FranchiseState") = m_objFranchiseInfo.szState 
       Session("FranchiseZip") = m_objFranchiseInfo.szZip 
       Session("FranchisePhone") = m_objFranchiseInfo.szPhone 
       Session("FranchiseFax") = m_objFranchiseInfo.szFax 
       Session("FranchiseEmail") = m_objFranchiseInfo.szEmail 
      Else 
       Response.Redirect("~\FranchiseInfo.aspx") 
      End If 
     End If 

    End Sub 

    Public Function DecryptData(
    ByVal encryptedtext As String) As String 

     ' Convert the encrypted text string to a byte array. 
     Dim encryptedBytes() As Byte = Convert.FromBase64String(encryptedtext) 

     ' Create the stream. 
     Dim ms As New System.IO.MemoryStream 
     ' Create the decoder to write to the stream. 
     Dim decStream As New CryptoStream(ms, 
      TripleDES.CreateDecryptor(), 
      System.Security.Cryptography.CryptoStreamMode.Write) 

     ' Use the crypto stream to write the byte array to the stream. 
     decStream.Write(encryptedBytes, 0, encryptedBytes.Length) 
     decStream.FlushFinalBlock() 

     ' Convert the plaintext stream to a string. 
     Return System.Text.Encoding.Unicode.GetString(ms.ToArray) 
    End Function 

    Private Function TruncateHash(
    ByVal key As String, 
    ByVal length As Integer) As Byte() 

     Dim sha1 As New SHA1CryptoServiceProvider 

     ' Hash the key. 
     Dim keyBytes() As Byte = 
      System.Text.Encoding.Unicode.GetBytes(key) 
     Dim hash() As Byte = sha1.ComputeHash(keyBytes) 

     ' Truncate or pad the hash. 
     ReDim Preserve hash(length - 1) 
     Return hash 
    End Function 

    Sub New(ByVal key As String) 
     ' Initialize the crypto provider. 
     TripleDes.Key = TruncateHash(key, TripleDes.KeySize \ 8) 
     TripleDes.IV = TruncateHash("", TripleDes.BlockSize \ 8) 
    End Sub 

    Public Function EncryptData(
    ByVal plaintext As String) As String 

     ' Convert the plaintext string to a byte array. 
     Dim plaintextBytes() As Byte = 
      System.Text.Encoding.Unicode.GetBytes(plaintext) 

     ' Create the stream. 
     Dim ms As New System.IO.MemoryStream 
     ' Create the encoder to write to the stream. 
     Dim encStream As New CryptoStream(ms, 
      TripleDes.CreateEncryptor(), 
      System.Security.Cryptography.CryptoStreamMode.Write) 

     ' Use the crypto stream to write the byte array to the stream. 
     encStream.Write(plaintextBytes, 0, plaintextBytes.Length) 
     encStream.FlushFinalBlock() 

     ' Convert the encrypted stream to a printable string. 
     Return Convert.ToBase64String(ms.ToArray) 
    End Function 

End Class 

每個幫助是值得歡迎的。 在此先感謝,Laziale

+0

你的編譯配置是否設置爲'Debug'或'Release'? –

+0

構建配置設置爲調試 – Laziale

+0

重複http://stackoverflow.com/questions/3144880/visual-studio-2010-debugger-skipping – Michael

回答

1

如果您使用ASP.net開發服務器託管,我發現即使Visual Studio已停止,該進程仍在執行代碼時發生了這種情況。當您開始一個新的調試會話時,它會嘗試關注兩個會話。我認爲這可能發生在您點擊停止按鈕而不是關閉瀏覽器窗口並且存在長時間運行或異步進程時。

嘗試右鍵單擊任務欄中的ASP.net開發服務器圖標並選擇停止,然後開始調試。