ошибка CS1022: ожидается определение типа или пространства имен или конец файла
Я создаю приложение для обмена сообщениями для andriod / ios, но я совершенно новичок в c # и работе с сетями, я прошел первые шаги простого руководства по сокетам, чтобы начать работу в сети (https://www.youtube.com/watch?v=KxdOOk6d_I0), но я получаю сообщение об ошибке:
ошибка «CS1022: определение типа или пространства имен или ожидаемый конец файла».
Я предполагаю, что это как-то связано с пространством имен, потому что я новичок в c # и на самом деле не понимаю, что делает пространство имен, но мой компилятор говорит, что ошибок нет (я использую код Visual Studio, если это имеет значение ) но это может быть что-то еще.
Он должен сказать сервер запущен . «или выдать исключение, но это то, что я получаю каждый раз:
[Запуск] моно «C: Users Aidan AppData Roaming Code User cs-script.user cscs.exe» «d:! Информатика !! NEA! Test stuff network server_test program. cs «Ошибка: указанный файл не может быть скомпилирован.
csscript.CompilerException: d:! computer science !! NEA! test stuff network server_test program.cs (7,127): ошибка CS1513:> ожидается d:! computer science !! NEA! test stuff network server_test program.cs (37,1): ошибка CS1022: определение типа или пространства имен или ожидаемый конец файла
at csscript.CSExecutor.ProcessCompilingResult (результаты System.CodeDom.Compiler.CompilerResults, System.CodeDom.Compiler.CompilerParameters compilerParams, синтаксический анализатор CSScriptLibrary.ScriptParser, System.String scriptFileName, дополнительное имя System.String [0], [0]. в: 0 в csscript.CSExecutor.Compile (System.String scriptFileName) [0x0080d] в: 0 в csscript.CSExecutor.ExecuteImpl () [0x005a1] в: 0
[Готово] выход с кодом = 1 через 1,795 секунды
Источник
error CS1022: Type or namespace definition, or end-of-file expected
I’m creating a messaging application for andriod/ios, but I am completely new to c# and networking, I’ve followed the first steps of a simple socket tutorial to get me started in networking (https://www.youtube.com/watch?v=KxdOOk6d_I0) but I get the error:
error «CS1022: Type or namespace definition, or end-of-file expected».
I’m assuming that it has something to do with the namespace because im new to c# and don’t actually understand what the namespace does, but my compiler says there are no errors (I’m using visual studio code if that makes a difference) but it may be something else.
it should say server started. » or throw up an exeption but this is what im getting every time:
[Running] mono «C:UsersAidanAppDataRoamingCodeUsercs-script.usercscs.exe» «d:!computer science!!NEA!test stuffnetworkingserver_testprogram.cs» Error: Specified file could not be compiled.
csscript.CompilerException: d:!computer science!!NEA!test stuffnetworkingserver_testprogram.cs(7,127): error CS1513: > expected d:!computer science!!NEA!test stuffnetworkingserver_testprogram.cs(37,1): error CS1022: Type or namespace definition, or end-of-file expected
at csscript.CSExecutor.ProcessCompilingResult (System.CodeDom.Compiler.CompilerResults results, System.CodeDom.Compiler.CompilerParameters compilerParams, CSScriptLibrary.ScriptParser parser, System.String scriptFileName, System.String assemblyFileName, System.String[] additionalDependencies) [0x00102] in :0 at csscript.CSExecutor.Compile (System.String scriptFileName) [0x0080d] in :0 at csscript.CSExecutor.ExecuteImpl () [0x005a1] in :0
[Done] exited with code=1 in 1.795 seconds
Источник
I’m creating a messaging application for andriod/ios, but I am completely new to c# and networking, I’ve followed the first steps of a simple socket tutorial to get me started in networking (https://www.youtube.com/watch?v=KxdOOk6d_I0) but I get the error:
error «CS1022: Type or namespace definition, or end-of-file expected».
I’m assuming that it has something to do with the namespace because im new to c# and don’t actually understand what the namespace does, but my compiler says there are no errors (I’m using visual studio code if that makes a difference) but it may be something else.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Sockets;
namespace server_test
{
class program
{
static void main(string[] args)
{
IPAdress ip = Dns.GetHostEntry("localhost").AdressList[0];
TcpListener server = new TcpListener(ip, 8080);
TcpClient client = default(TcpClient);
try
{
server.Start();
Console.WriteLine("server started...");
Console.ReadLine();
}catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Console.ReadLine();
}
}
}
}
it should say server started…» or throw up an exeption but this is what im getting every time:
[Running] mono «C:UsersAidanAppDataRoamingCodeUsercs-script.usercscs.exe» «d:!computer science!!NEA!test stuffnetworkingserver_testprogram.cs»
Error: Specified file could not be compiled.csscript.CompilerException: d:!computer science!!NEA!test stuffnetworkingserver_testprogram.cs(7,127): error CS1513: } expected
d:!computer science!!NEA!test stuffnetworkingserver_testprogram.cs(37,1): error CS1022: Type or namespace definition, or end-of-file expectedat csscript.CSExecutor.ProcessCompilingResult (System.CodeDom.Compiler.CompilerResults results, System.CodeDom.Compiler.CompilerParameters compilerParams, CSScriptLibrary.ScriptParser parser, System.String scriptFileName, System.String assemblyFileName, System.String[] additionalDependencies) [0x00102] in :0
at csscript.CSExecutor.Compile (System.String scriptFileName) [0x0080d] in :0
at csscript.CSExecutor.ExecuteImpl () [0x005a1] in :0[Done] exited with code=1 in 1.795 seconds
Permalink
Cannot retrieve contributors at this time
title | ms.date | ms.prod | ms.technology | ms.topic | f1_keywords | dev_langs | helpviewer_keywords | ms.assetid | caps.latest.revision | author | ms.author | translation.priority.ht | translation.priority.mt | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Compiler Error CS1022 | Microsoft Docs |
2015-07-20 |
.net |
devlang-csharp |
article |
CS1022 |
CSharp |
CS1022 |
76b9f32b-2ebf-471d-a635-852daf8877d7 |
6 |
BillWagner |
wiwagn |
|
|
Compiler Error CS1022
Type or namespace definition, or end-of-file expected
A source-code file does not have a matching set of braces.
The following sample generates CS1022:
// CS1022.cs
namespace x
{
}
} // CS1022
Permalink
Cannot retrieve contributors at this time
title | ms.date | ms.prod | ms.technology | ms.topic | f1_keywords | dev_langs | helpviewer_keywords | ms.assetid | caps.latest.revision | author | ms.author | translation.priority.ht | translation.priority.mt | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Compiler Error CS1022 | Microsoft Docs |
2015-07-20 |
.net |
devlang-csharp |
article |
CS1022 |
CSharp |
CS1022 |
76b9f32b-2ebf-471d-a635-852daf8877d7 |
6 |
BillWagner |
wiwagn |
|
|
Compiler Error CS1022
Type or namespace definition, or end-of-file expected
A source-code file does not have a matching set of braces.
The following sample generates CS1022:
// CS1022.cs
namespace x
{
}
} // CS1022