[英]Use external, non native, dll in VS C# class application
I tried to follow some examples but I must be missing something here... I am creating a class application .NET Framework 4. I downloaded a required dll from the internet which I need to reference in my class application.
谢谢
案例 1:如果您使用 Visual Studio 插件从 NuGet 下载了 dll,那么您无需担心任何事情。
现在,在代码签入时,您不应签入 dll 文件,而应仅签入 package.config 文件。
案例 2:如果您从其他来源手动下载了 dll,但没有使用 Visual Studio 插件,那么您必须手动将 dll 引用添加到您的项目中。
您还应该与代码存储库共享这些 dll。 因此,其他人不需要在其他一些网站上搜索它。
案例 3:您可以将这些 dll 上传到 Nuget.org(如果安全不是问题)并使其可用。 在这种情况下,这将是一次性过程,您可以像案例 1 一样更新 package.config:
如果您想将 dll 导入您的项目,您可以参考以下步骤。
1.点击Project
=> Add Reference...
2.点击Browser
=> Add the dll your want
=>点击OK
3.添加using语句,调用dll中的方法。
using System;
using testdll;
namespace import_dll
{
class Program
{
static void Main(string[] args)
{
// Class1 is the class in testdll.dll
Class1 class1 = new Class1();
// Text is the method defined in Class1
class1.Text();
Console.ReadKey();
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.