c# monotorrent客户端嵌入问题

本文关键字:问题 客户端 monotorrent | 更新日期: 2023-09-27 18:02:35

我需要在我的c#应用程序中嵌入torrent客户端(通过.torrent文件下载文件的能力)。我使用monotorrent库来做到这一点。我需要写一个windows应用程序,可以下载文件到我的本地文件夹。

我已经从这里下载了c#项目的汇编http://www.monotorrent.com/projects/list_files/monotorrent

下面是我使用的代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MonoTorrent.Client;
using MonoTorrent.Client.Encryption;
using System.IO;
using MonoTorrent.Common;
using System.Net;

namespace monotorrent
{
public partial class Form1 : Form
{
    ClientEngine engine;
    public Form1()
    {
        InitializeComponent();
    }
    private void button1_Click(object sender, EventArgs e)
    {
        Torrent torrent = Torrent.Load("C:''1.torrent");
        // Create the manager which will download the torrent to savePath
        // using the default settings.
        TorrentManager manager = new TorrentManager(torrent, "E:''torrent", new TorrentSettings());
        // Register the manager with the engine
        this.engine.Register(manager);
        // Begin the download. It is not necessary to call HashCheck on the manager
        // before starting the download. If a hash check has not been performed, the
        // manager will enter the Hashing state and perform a hash check before it
        // begins downloading.
        // If the torrent is fully downloaded already, calling 'Start' will place
        // the manager in the Seeding state.
        manager.Start();
    }
}
}

当我运行代码并按下下载按钮时,我得到了一个错误:

无法加载"MonoTorrent.Common"类型。Torrent" from assembly "monotorrent, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null".

我认为这是装配的问题。但是我在哪里可以得到一个正常的程序集(.dll) ?

请帮我解决这个问题。

注:如果你知道更简单的解决方案来嵌入torrent客户端到windows窗体应用程序-你是受欢迎的=)

c# monotorrent客户端嵌入问题

尝试自己编译库(通过打开VS并进行构建),而不是使用您在网上找到的一些库(*.dll)。还有,所有的依赖项都在那里吗?

在您的项目中放置monotorrent.dll的引用。你可以从这里获取或者从这里编译源码