Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
private void btnStart_Click(object sender, EventArgs e)
        {
            txtStatus.Text += "Server starting...";
            System.Net.IPAddress ip = new System.Net.IPAddress(long.Parse(txtHost.Text));
            server.Start(ip, Convert.ToInt32(txtPort.Text));
        }

Quote:
In the IpAddress part, this part is long.Parse(txtHost.Text)

IpAddress 부분에서 long.Parse(txtHost.Text) 이부분이
System.FormatException: 'Input string was not in a correct format.'

Quote:
an error occurs
txtHost is the text with the IP address, but the problem is not solved

오류발생합니다
txtHost 가 ip 주소를 적은 텍스트인데 문제해결이안됩니다

What I have tried:

Quote:
It seems to be a type problem, but I don't know how to change the code.
If anyone knows, please share information
타입형 문제인것 같은데 코드를바꿔야하는 방법을 모르겠습니다.
알고 계시는 분은 정보공유좀 부탁드리겠습니다
Posted
Updated 30-Aug-22 19:37pm
v2

1 solution

This is an English language site, and we can only accept and answer questions in that language.
I have run this through Google Translate to produce a probably-good version, but you should check it and make sure it does say what you are actually asking.

Teh error is simple: the text in your text box txtHost cannot be interpreted as a long value: it contains characters other than the digits '0' to '9'.

That can't be "fixed" as it's an input data problem, and we have no access to that. But ... at a guess, it's an IP address like "192.168.0.1" which can;t be read as a long.

Start with the debugger, and find out exactly what the TextBox contains, then look for a solution from there. I'd guess that you want to use IPAddress.Parse Method (System.Net) | Microsoft Docs[^] rather than constructing a new IPAddress instance - but without access to you data, we can't be sure.

Google translate:
이것은 영어 사이트이며 해당 언어로만 질문을 수락하고 답변할 수 있습니다.
아마도 좋은 버전을 생성하기 위해 Google 번역을 통해 이것을 실행했지만, 당신은 그것을 확인하고 당신이 실제로 묻는 것을 말하는지 확인해야 합니다.

오류는 간단합니다. 텍스트 상자 txtHost의 텍스트는 long 값으로 해석될 수 없습니다. 여기에는 '0'에서 '9'까지의 숫자가 아닌 다른 문자가 포함되어 있습니다.

그것은 입력 데이터 문제이기 때문에 "고칠" 수 없으며 우리는 그것에 접근할 수 없습니다. 하지만 ... 추측컨데 "192.168.0.1"과 같이 길게 읽을 수 없는 IP 주소입니다.

디버거로 시작하여 TextBox에 포함된 내용을 정확히 찾은 다음 거기에서 솔루션을 찾으십시오. 나는 당신이 새로운 IPAddress 인스턴스를 생성하는 것보다 사용하기를 원할 것이라고 추측합니다. 그러나 당신의 데이터에 접근하지 않는다면 우리는 확신할 수 없습니다.
 
Share this answer
 

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