简体   繁体   English

如何在 C# 中毫无问题地添加 dll 参考?

[英]How can I add a dll reference in C# without problems?

I'm kinda new at this, this is my first question here, but here it goes.我对此有点陌生,这是我在这里的第一个问题,但就在这里。

I've got a server and a client using TcpListenet and TcpClient, I also created a Class Library where I have my shared classes, I have already added the reference for this class in both the server and the client projects, I've also added the "using" statement to import this class.我有一个使用 TcpListenet 和 TcpClient 的服务器和一个客户端,我还创建了一个 Class 库,其中有我的共享类,我已经在服务器和客户端项目中添加了这个 class 的参考,我还添加了“使用”语句导入此 class。 When I run both the client and the server on VS it works just fine, hoewever, when I try to test using multiple clients by opening the client.exe files, I get an error saying that my library could not be found, and also this: Set the register value set the registry value [HKLM\Software\Microsoft\Fusion.EnableLog] (DWORD) to 1.当我在 VS 上同时运行客户端和服务器时,它工作得很好,但是,当我尝试通过打开 client.exe 文件来测试使用多个客户端时,我收到一条错误消息,提示找不到我的库,还有这个: 设置寄存器值 设置注册表值 [HKLM\Software\Microsoft\Fusion.EnableLog] (DWORD) 为 1。

I'm not sure why it works by running it on VS but not by executing the.exe files.我不确定为什么它通过在 VS 上运行而不是通过执行 .exe 文件来工作。 Please help me.请帮我。

You have two options here:您在这里有两个选择:

  1. Put your DLL to Global Assembly Cache(GAC)将您的DLL放入全局程序集缓存(GAC)
  2. For your files Properties "Build Action" as "Content" and for "Copy to output directory" as "Copy Always" or "Copy if Newer" (this will put the file only when there are changes into it).对于您的文件属性“构建操作”作为“内容”,将“复制到 output 目录”作为“始终复制”或“如果较新则复制”(这只会在文件发生更改时放置文件)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在C#应用程序中添加对基于C的DLL的引用? - How can I add a reference to a C-based DLL in my C# application? 如何在我的 C# Visual Studio 项目中添加 VC++ DLL 作为参考? - How can I add a VC++ DLL as a reference in my C# Visual Studio project? 如何在C#中使用DLL函数而不添加DLL作为参考? - How do I use a DLL function in C# without adding the DLL as reference? 从C#应用程序添加一个引用到没有/ clr编译的DLL? - Add a Reference from a C# App to a DLL compiled without /clr? 添加/删除DLL参考C# - add/remove dll reference c# 如何使用 codedom 将 dll 嵌入到输出程序集中,并使用 C# 将其用作参考? - How can I embed a dll to the output assembly with codedom, and use it as reference using C#? 如何使用清单在vb6库项目中引用Com可见的C#dll? - How can I reference a com visible C# dll in a vb6 library project using a manifest? 如何将DLL引用添加到ASP.NET C#Web应用程序(该dll是基础c库的包装) - How to add a DLL reference to a ASP.NET C# web application (the dll is a wrapper for underlying c libraries) 如何在C#中引用DLL,而不是特定版本? - How do I reference a DLL in my C# but not a specific version? 我如何在没有任何公共成员的情况下引用dll? - How can I reference a dll without any public members?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM