.net - 何时加载引用的程序集?

标签 .net dll reference

我编写了一个引用 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/

相关文章:

.net - 在 dacpac 文件中包含 DLL

JavaScript 变量引用

ios - 有一个非可选的弱引用有意义吗?

c++ - 使用指向引用 vector 的指针 vector 是非法的?

c# - 桌面应用程序中的数据可视化

c# - 如何通过 app.config 变量覆盖 settings.settings 变量

c++ - Qt 非静态链接和 .pro 文件

c# - 如何在 ruby​​ 中调用 C# dll?

c# - 您能否使用 linq 查看两个 IEnumerables 数据是否包含任何公共(public)条目?

c# - 如果它是锁中的最后一条语句,覆盖锁对象是否不好?