Difference between .Net and VC dll delayload?
-
Hi all, Do you noticed a difference about dll delay-load for assembly? We know that assembly is delay-loaded by default, and it is configurable for VC. But there is a difference on when will it loaded... in VC, the dll will be loaded only when code reached exactly the line that need another dll. in .Net, it will load once it get into the method that calls another dll's code. ex: Dll1.dll class Class1 { void Fun() { int dummy = 0; Dll2.Class1.Fun(); } } Dll2.dll class Class1 { void Fun(){} } For VC, it load Dll2 when code reached "Dll2.Class1.Fun();" For .Net, it load Dll2 when code reached "int dummy = 0;" any one can tell me why there is such a difference? thanks in advance.
do it.
-
Hi all, Do you noticed a difference about dll delay-load for assembly? We know that assembly is delay-loaded by default, and it is configurable for VC. But there is a difference on when will it loaded... in VC, the dll will be loaded only when code reached exactly the line that need another dll. in .Net, it will load once it get into the method that calls another dll's code. ex: Dll1.dll class Class1 { void Fun() { int dummy = 0; Dll2.Class1.Fun(); } } Dll2.dll class Class1 { void Fun(){} } For VC, it load Dll2 when code reached "Dll2.Class1.Fun();" For .Net, it load Dll2 when code reached "int dummy = 0;" any one can tell me why there is such a difference? thanks in advance.
do it.
You are quite allright. why is it so? In C you just blindly on the address and hope it works. In .NET the JIT (Just In Time compiler) will compile the method on first call (i.e. transform it from MSIL to machine language), doing so it will make sure all calls are valid, hence it needs to check that all method call are reachable and with the right signature, i.e. it needs to load the DLL and check a few things such as: the dll exist, the version is right, the target methods exist, with the right signature, etc... Otherwise the method will be deemed invalid and an exception will be thrown
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.