简体   繁体   English

如何访问 bin 子目录中的 dll。 .net?

[英]how access the dll in sub directory of bin . .net?

i am adding a new folder to bin in solution explorer in vs 2010 and in that folder i am having one dll file and i want to access that dll file in the program in c#.net?我在 vs 2010 的解决方案资源管理器中向 bin 添加了一个新文件夹,在该文件夹中我有一个 dll 文件,我想在 c#.net 的程序中访问该 dll 文件? i used using in code but i did not get the intelligence of that dll.我在代码中使用过,但我没有得到 dll 的智能。 please help me?请帮我?

Try adding it as a reference.尝试将其添加为参考。

In Solution Explorer, right-click the project node and click Add Reference.在解决方案资源管理器中,右键单击项目节点,然后单击添加引用。

In the Add Reference dialog box, browse to it.在“添加引用”对话框中,浏览到它。

How to: Add or Remove References in Visual Studio (MSDN)如何:在 Visual Studio (MSDN) 中添加或删除引用

Don't add files to the target bin folder of your solution as this folder is controlled by Visual Studio.不要将文件添加到解决方案的目标 bin 文件夹,因为此文件夹由 Visual Studio 控制。

If the library is a .NET or COM library add it as a reference.如果库是 .NET 或 COM 库,请将其添加为参考。

If the libary is a native dll do the following:如果库是本机 dll,请执行以下操作:

  1. Add the file to your project将文件添加到您的项目中
  2. Set the Build Action property to ContentBuild Action属性设置为Content
  3. Set the Copy to Output Directory property to Copy always复制到 Output 目录属性设置为始终复制

Then Visual Studio will make sure that the library gets copied to the target folder automatically where you can access it.然后 Visual Studio 将确保该库自动复制到您可以访问它的目标文件夹。

I am assuming you asking about web solutions.我假设您询问 web 解决方案。 In web solutions bins doesn't have any sub folder.在 web 解决方案 bin 中没有任何子文件夹。 All the dlls reside just in the bin itself.所有的 dll 都位于 bin 本身中。

So drop the dll directly in bin...rebuild the full solution and you will get what you want.因此,将 dll 直接放入 bin 中...重建完整的解决方案,您将得到您想要的。

Thanks谢谢

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM