我编写了一个引用 Microsoft.Web.Administration.dll 的程序,
在 Windows Server 2003 上不存在。
如果 os 是 2003,程序会检查 os 并且不引用 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>
当我在 Windows Server 2003 上测试这个程序时,发生错误,告诉我它无法找到 Microsoft.Web.Administration.dll。
但是当我将 if-else 块分成如下两种不同的方法时,并没有发生错误。
if(OSVersion == WindowsServer2003)
//do the job without referencing the Microsoft.Web.Administration.<br>
else if(OSVersion == WindowsServer2008)
//DoIt2008Style();
所以我想更详细地了解引用文件加载时间。
你能指点我一些资源吗?
最佳答案
当您输入引用另一个程序集中的类型的方法时。 Here是尝试延迟加载 x86 和 x64 程序集时的一个示例。
关于.net - 何时加载引用的程序集?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2785520/