When I create a new AppDomain using AppDomain.CreateDomain in C#, will static constructors be called as asseblies are loaded inside the newly created AppDomain?
The assemblies in question have already been loaded into the current domain.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No – static constructors will only be called the first time a static member is accessed or an instance is created.
The static constructor will be invoked once per
AppDomainthough, if that’s what you were concerned about. It’s not like having executed once in a differentAppDomain, the types in the newAppDomainget left uninitialized 🙂Note that type initializers for types without static constructors may be executed earlier or later than those for types with static constructors, and the precise implementation details changed for .NET 4.