What happens if the static class Load fails

Lets say the type static class MyClass fails to load during AppDomain.AssemblyLoad. Maybe the class contains a static property which reads the connection string from the config. Will further references to types in said DLL cause AppDomain.AssemblyLoad to attempt to re-load the DLL?

In other words, will AppDomain.AssemblyLoad retry a DLL that has previously failed to load?

Jon Skeet
people
quotationmark

so will it reload again for further calls on some methods on that class?

No. If type initialization fails for a particular type, that type is effectively useless throught the lifecycle of the AppDomain. Any further attempt to use the type will simply throw the same TypeInitializationException again immediately, without retrying. Avoid fallible type initialization wherever possible.

If you create a new AppDomain then that will try to initialize the type again.

people

See more on this question at Stackoverflow