Delay loading in C #?

Is there such a thing as dll loading delay in C #? I know this can be done in C ++, but what about managed code?

+8
source share
3 answers

.NET does this automatically; everything is loaded by default by default.

+13
source

This article details how it works in .NET. Summary of key points:

There are several different ways to load assemblies in .NET. When creating a sample project, assemblies usually come from:

  • List of assembly links for a top-level executable project

  • Link building for reference projects

  • Dynamically loadable assemblies using runtime loading via AppDomain or Reflection loading

and

.NET automatically loads mscorlib (most of the System namespace) as part of the .NET runtime deployment process, which raises the .NET runtime environment in EXE applications, or some other runtime placement environment (hosted while running on servers such as IIS, SQL Server or COM Interop).

and

  • Links to dependent assemblies are not preloaded at application startup (by default)

  • Dependent assemblies that are not referenced by executable code never load

  • Dependent assemblies just in time load at the first link in the code

  • Once assemblies are loaded, they can never be unloaded, unless the application domain in which they are hosted is unloaded.

+1
source

Yes it is. You do not include the DLL as a link in your project and where you want to download or use it, you call the Assembly.LoadFile method.

This blog post does a pretty good job of code to describe how to do this.

0
source

Source: https://habr.com/ru/post/902853/


All Articles