2012-11-05 4 views
-2

가능한 중복 : 지난 두 검사에 표시 어떤 메시지 상자가없는 이유는호출되지 않은 경우. C#을

Match match = regex.Match(responseFromServer); 
if (match.Success) 
{ 
    var input = responseFromServer; 
    var split = input.Split(':'); 
    var final = split[3]; 
    ProcessStartInfo mcStartInfo = new Shitocode; 
    Process.Start(mcStartInfo); 
    this.Close(); 
} 
else if (responseFromServer == " Bad Login") 
{ 
    MessageBox.Show("Uncorrect login/password!"); 
} 
else if (responseFromServer == " Old version") 
{ 
    MessageBox.Show("Launcher is old!"); 
} 

:
incorrectly checks the response c#

나는 코드가?

if (match.Success) 
{ 
    var input = responseFromServer; 
    var split = input.Split(':'); 
    var final = split[3]; 
    ProcessStartInfo mcStartInfo = new Shitocode; 
    Process.Start(mcStartInfo); 
    this.Close(); 
} 
else if (responseFromServer.Equals("Bad Login")) 
{ 
    MessageBox.Show("Uncorrect login/password!"); 
} 
else if (responseFromServer.Equals("Old Version")) 
{ 
    MessageBox.Show("Launcher is old!"); 
} 

내가 잘못된 암호를 입력하지만, 코드를 통해 이동 responseFromServer의 값을 확인, 그냥 브레이킹을 설정 메시지 박스

+0

을 변화시킬 수 debug 문을 추가하여'responseFromServer'가 무엇인지 확인하십시오 :'System.Diagnostics.Debug.WriteLine (responseFromServer);'그러면 else if 문이 좋은지 확인할 수 있습니다. – SynerCoder

+0

응답에 대한 확신이 있습니까? 서버가 "Bad login"또는 ""Old Version ""에 응답하지 않을 수 있습니다. 그 코드를 디버깅 해보십시오. – ragatskynet

+0

그럼 서버의 응답은 무엇입니까? – Jodrell

답변

0

아마도 responseFromServer이 사용자가 확인한 값 (잘못된 로그인 및 이전 버전)과 일치하지 않을 수 있습니다.
경우 시퀀스의 끝에서 또 다른 다른 을 추가하고있어 무엇을 찾아보십시오.

if (match.Success) 
{ 
    //your code 
} 
else if (responseFromServer.Equals("Bad Login")) 
{ 
    MessageBox.Show("Uncorrect login/password!"); 
} 
else if (responseFromServer.Equals("Old Version")) 
{ 
    MessageBox.Show("Launcher is old!"); 
} 
else 
{ 
    MessageBox.Show("Cannot login, unknown response: " + responseFromServer) 
} 

코멘트

당신이 정확한 메시지하지 않습니다,하지만 당신이 어떤 정확한 문자열을 포함하는 것으로 알고 있다면 후 편집, 두 responseFromServer.Equals()responseFromServer.Contains()

+0

좋아요, 암호를 잘못 입력했는데 버튼을 누르십시오 "로그인 할 수 없습니다, 알 수없는 응답 : 로그인이 잘못되었습니다"라는 메시지 상자가 나타납니다 – user1798736

+0

문제 해결 방법에 대한 제안 사항이 추가되었습니다 –

0

을 열지 않습니다

나는 다른 일을하는 것을 시도했다 이것을 두 경우에 복사하고 코드에서 비교해보십시오. "나쁜 로그인"이전의 첫 번째 코드 부분에 공백이 있음을 알았지 만 그 이유는 확실하지 않습니다.

1
string s = instxtbox.Text; 
     string[] s1 = new string[3]; 
     s1[0] = " "; 
     s1[1] = " "; 
     s1[2] = " "; 

     string[] portion = s.Split(s1, StringSplitOptions.RemoveEmptyEntries); 
     int val = Convert.ToInt32(portion[2]); 

     string reg = portion[1]; 



     if (reg == "ax") 
      axtxtbox.Text = portion[2]; 

     else if (reg == "bx") 
      bxtxtbox.Text = portion[2]; 
     else if (reg == "cx") 
      cxtxtbox.Text = portion[2]; 
     else if (reg == "dx") 
      dxtxtbox.Text = portion[2]; 
관련 문제