何时引用了Assemblies加载?

Yeo*_*nho 5 .net dll reference

我编写了一个程序来引用Microsoft.Web.Administration.dll,这在Windows Server 2003上不存在.

程序检查操作系统,如果操作系统是2003,则不引用dll.

if(OSVersion == WindowsServer2003)
    //do the job without referencing the Microsoft.Web.Administration.<br>
else if(OSVersion == WindowsServer2008)
   //reference the Microsoft.Web.Administration.dll file.<br>
Run Code Online (Sandbox Code Playgroud)

当我在Windows Server 2003上测试此程序时,发生错误告诉我它无法找到Microsoft.Web.Administration.dll.
但是当我将if-else块分成如下2种不同的方法时,并没有发生错误.

if(OSVersion == WindowsServer2003)
   //do the job without referencing the Microsoft.Web.Administration.<br>
else if(OSVersion == WindowsServer2008)
   //DoIt2008Style();
Run Code Online (Sandbox Code Playgroud)

所以我想更详细地了解参考文件加载时间.你能指点我一些资源吗?

Ian*_*vis 5

当您输入引用另一个程序集中的类型的方法时.以下是尝试延迟加载x86和x64程序集时的示例.