将所需的.dll添加到我的发布中 [英] adding needed .dll to my publish

查看:113
本文介绍了将所需的.dll添加到我的发布中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哦,我有一个 需要.dll文件才能工作的类。 现在我在我的调试中有更多的编程工作,并且在我的发布模式下,但是当我尝试发布项目时,它无法存档.dll。它给了我一个运行时错误。  



现在试过这个: 




  • 右键单击解决方案查看器中的项目

  • 选择Add - Existing Item

  • 浏览到DLL并单击Add   添加按钮旁边的小箭头和
    添加为链接

  • 在解决方案查看器中选择您的DLL

  • 右键单击它并选择Properties

  • Set  Build Action    内容

  • Set  复制到输出目录  复制
    如果更新

但它没有工作。


我仍然得到同样的错误



解决方案

如果您需要一个DLL才能使您的应用程序正常工作,那么将其添加到解决方案中的方法并不正确。如果DLL是另一个.NET程序集,那么您应该已经将它添加为对应的参考项目(二进制或通过NuGet)。
在这种情况下,DLL已经在输出文件夹中,所以你不需要做任何事情。


如果DLL是在运行时动态加载的第三方DLL然后大多数团队在他们的解决方案下为第三方二进制文件(例如依赖项)创建一个文件夹。然后将DLL放在那里。你不需要将它添加到解决方案但是要确保它获取
包含在源代码管理系统中。在项目的post build事件中编写xcopy命令将DLL复制到输出目录无论如何,你需要这个来进行调试。这样的事情。

 xcopy" 


(SolutionDir)Dependencies \ MyDll.dll" "

(TARGETDIR)" / R / Y


这是从内存中提取的,但它会从你的"依赖项"中复制DLL(或你想要的任何文件)。解决方案根目录中的文件夹到当前项目的输出目录,覆盖任何现有文件。由于它在每个构建版本上运行,因此它将位于
输出目录中。


oh I have a  class that need need a .dll file to work.  now I have the programming work in my debug more and in my release mode but when I try to publish the project it cannot file the .dll. and it gives me a runtime error.  

now Tried this : 

  • Right click project in Solution Viewer
  • Select Add - Existing Item
  • Browse to the DLL and click Add or the little arrow next to the Add button and Add as Link
  • Select your DLL in the Solution Viewer
  • Right click it and select Properties
  • Set Build Action to Content
  • Set Copy to Output Directory to Copy if newer

but it did not  work.

I am still getting the same error

解决方案

If you need a DLL in order for your app to work then adding it to the solution isn't the correct approach. If the DLL is another .NET assembly then you should have already added it as a reference to the corresponding project (either binary or via NuGet). In that case the DLL will already be in the output folder so you don't need to do anything.

If the DLL is a third party DLL that is dynamically loaded at runtime then most teams create a folder under their solution for third party binaries (e.g. dependencies). Then put the DLL in there. You don't need to add it to the solution but be sure it gets included in your source control system. In your project's post build event write the xcopy command to copy the DLL to the output directory of the project. You'll need this for debugging anyway. Something like this.

xcopy "


(SolutionDir)Dependencies\MyDll.dll" "


(TargetDir)" /R /Y

This is pulled from memory but it'll copy the DLL (or any file you want) from your "dependencies" folder in the solution root to the output directory of the current project, overwriting any existing file. Since it runs on each build it'll be in the output directory.


这篇关于将所需的.dll添加到我的发布中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆