How are DLLs loaded by the CLR?

前端 未结 4 689
名媛妹妹
名媛妹妹 2020-12-01 04:58

My assumption was always that the CLR loaded all of the DLLs it needed on startup of the app domain. However, I\'ve written an example that makes me question this assumption

4条回答
  •  萌比男神i
    2020-12-01 05:30

    The CLR loads the assemblies on demand. When you execute a method, it looks to see where it is (which module etc.), and if it isn't loaded, it loads it.

    Here is an article on CLR performance and talks about loading assemblies:

    When the CLR just-in-time (JIT) compiles the Start method it needs to load all assemblies referenced within that method. This means that all assemblies referenced in the exception handler will be loaded, even though they might not be needed most of the time the application is executed.

    This article is for SilverLight, but it does talk a little about what happens with the CLR.

提交回复
热议问题