0

Я пытаюсь запустить консольное приложение, которое содержит в себе телеграм бота. Делаю я это через чистую консоль Ubuntu на Proxmox, через mono. При команде csc Program.cs мне выводится ошибка о том, что нету библиотеки:


Program.cs(4,7): error CS0246: The type or namespace name 'Telegram' could not be found (are you missing a using directive or an assembly reference?)
Program.cs(5,7): error CS0246: The type or namespace name 'Telegram' could not be found (are you missing a using directive or an assembly reference?)
Program.cs(6,7): error CS0246: The type or namespace name 'Telegram' could not be found (are you missing a using directive or an assembly reference?)
Program.cs(20,34): error CS0246: The type or namespace name 'ITelegramBotClient' could not be found (are you missing a using directive or an assembly reference?)
Program.cs(20,64): error CS0246: The type or namespace name 'Update' could not be found (are you missing a using directive or an assembly reference?)
Program.cs(39,33): error CS0246: The type or namespace name 'ITelegramBotClient' could not be found (are you missing a using directive or an assembly reference?)
Program.cs(12,24): error CS0246: The type or namespace name 'TelegramBotClient' could not be found (are you missing a using directive or an assembly reference?)

1 ответ 1

1

Возможно у вас возникли проблемы с зависимостями. Вы можете сделать это с помощью NuGet.

Поскольку вы используете Mono, вам нужно будет использовать NuGet для установки пакетов. Вот как это сделать:

Установите NuGet, если у вас его еще нет:

sudo apt-get install nuget

Создайте файл packages.config в каталоге вашего проекта с таким содержимым:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Telegram.Bot" version="17.0.0" />
</packages>

Замените 17.0.0 на желаемую версию библиотеки, если вам требуется другая версия.

В каталоге вашего проекта выполните следующую команду, чтобы установить зависимости:

nuget restore

Теперь, когда библиотека установлена, вы можете скомпилировать ваш проект, указав сборки в качестве ссылок:

csc Program.cs -r:./packages/Telegram.Bot.17.0.0/lib/netstandard2.0/Telegram.Bot.dll

Проверьте, что путь к файлу Telegram.Bot.dll указан верно. Если всё сделано правильно, ваш проект должен скомпилироваться без ошибок.

1
  • dotnet build, не? зачем руками эти ссылки прописывать?
    – aepot
    11 апр 2023 в 15:29

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.