何时被引用的装配体加载? [英] When are referenced Assemblies loaded?
问题描述
我写了一个程序,引用Microsoft.Web.Administration.dll,
在Windows Server 2003上不存在。
I wrote a program that makes a reference to Microsoft.Web.Administration.dll, which is not present on Windows Server 2003.
程序检查os,如果os是2003,则不引用dll。
The program checks for the os and does not reference the dll if the os is 2003.
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块分为两种不同的方法,如下所示,并且没有发生错误。
When I tested this program on Windows Server 2003, an error occured telling me it couldn't locate the Microsoft.Web.Administration.dll.
But when I separated the if-else block into 2 different methods as below, and the error did not occur.
if(OSVersion == WindowsServer2003)
//do the job without referencing the Microsoft.Web.Administration.<br>
else if(OSVersion == WindowsServer2008)
//DoIt2008Style();
所以我想更详细地了解参考文件加载时间。
你可以指点一些资源吗?
So I wanted to know about reference file loading time in more detail. could you point me to some resources?
推荐答案
当您输入引用另一个程序集中的类型的方法时。 这里是尝试延迟加载x86和x64程序集时的示例。
When you enter a method that references a type in another assembly. Here is an example when trying to delay load x86 and x64 assemblies.
这篇关于何时被引用的装配体加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!