如何将第三方 dll 从 bin 文件夹移动到 ASP.NET Web Forms 项目中的另一个文件夹?

How to move third party dlls from bin folder to another folder in ASP.NET Web Forms project?

Bin文件夹中有一些第三方dll。我想将它们移动到 root/lib 路径。我认为,将文件移动到 lib 文件夹是不够的。我怎样才能安全地做到这一点?这些是 dll;

更新: 我关注了 these instructions 但我得到了这样的错误; 命名空间 'System.Web'

中不存在类型或命名空间名称 'Optimization'

错误发生在这一行:using System.Web.Optimization;

我在根目录创建了一个新的 lib 文件夹,将 System.Web.Optimization.dll 文件移动到 lib。然后,我编辑了我的 web.config 如下;

    <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
  </dependentAssembly>
  <probing privatePath="bin;lib"/>
</assemblyBinding>

您可以通过下面的 link 查看。

How to move all referenced DLLs into seperate folder in c#?

希望对您有所帮助!

我在 this question 上找到了答案。所以,如果你想将第三方 dll 移动到新文件夹,你可以按照以下步骤操作;

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="Bin;folder_path"/>
    </assemblyBinding>
</runtime>
  1. 创建一个新文件夹来移动 dll
  2. 像上面那样更新web.config
  3. 在 system.web 个标签之间添加移动程序集

    <add assembly="System.Web.Optimization" />
    <add assembly="Telerik.Web.UI" />