C# monotorrent 客户端嵌入问题
我需要在我的 C# 应用程序中嵌入 torrent 客户端(能够通过 .torrent 文件下载文件)。我正在使用 monotorrent 库来做到这一点。 我需要编写 Windows 应用程序,可以通过 .torrent 文件将文件下载到我的本地文件夹。
我已经从这里下载了 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” “monotorrent,版本=1.0.0.0,文化=中性,PublicKeyToken=null”。
我认为这是装配的问题。但是我在哪里可以获得正常的程序集(.dll)?
请帮我解决这个问题。
PS,如果您知道将 torrent 客户端嵌入 Windows 窗体应用程序的更简单的解决方案 - 欢迎 =)
I need to embed torrent client (ability to download files by .torrent file) inside of my C# application. I am using monotorrent library to do that.
I need to write windows app that can download files to my local folder by .torrent file.
I have downloaded assembly for C# project from here http://www.monotorrent.com/projects/list_files/monotorrent
Here is code i am using :
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();
}
}
}
When i run the code and press download button i have got an error :
Cannot load type "MonoTorrent.Common.Torrent" from assembly "monotorrent, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null".
I think this is a problem with assembly . But where can i get a normal assembly(.dll) ?
Please help me to resolve this issue.
P.S. if you know more simple solution to embed torrent client to windows form app - You are wellcome =)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试自己编译该库(通过打开 VS 并进行构建),而不是使用您在网上找到的某些库(*.dll)。另外,所有依赖项都存在吗?
Try compiling the library yourself (by opening VS and doing a build) rather than using some lib (*.dll) you've found somewhere off the net. Also, are all the dependencies there?
在您的项目中放置对 monotorrent.dll 的引用。您可以在此处获取它,或者从此处
Place reference to monotorrent.dll in your project. You can get it here or compile from sources from here