App_Code 当依赖项在 bin 的子目录中时,AppInitialize 不编译

App_Code AppInitialize does not compile when dependencies within a sub directory of bin

我的 IIS 应用程序结构如下:

IIS Application\
  App_Code\
    AppInitializer.cs
  bin\
    CommonLibrary //junction folder
  ...
  foo.svc
  web.config

AppInitializer.cs 包含以下内容:

using CommonLibrary; //Dependency located inside the junction folder
namespace TD.Registry
{
  public class Hostbootstrapper
  {
    public static void AppInitialize()
    {
       //Some code here using CommonLibrary
    }
  }
}

当我在 Web 浏览器中浏览 IIS 应用程序时,出现编译错误并显示以下消息

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name 'CommonLibrary' could not be found (are you missing a using directive or an assembly reference?)

我通过在 web.config 中添加所需的程序集解决了编译错误,如下所示:

<system.web>
  <compilation debug="true" targetFramework="4.6.1">
    <assemblies>
      <add assembly="CommonLibrary"/>
    </assemblies>
  </compilation>
  
  ...
  
</system.web>