InitStatics() public static méthode

Initializes the system. This includes loading application settings from the configuration file. The application name should be scoped within the system. For non web applications, this method must be called directly from the main executable assembly and not from a supporting library. To debug this method, create a folder called C:\AnyoneFullControl and give Everyone full control. A file will appear in that folder explaining how far it got in init.
public static InitStatics ( SystemInitializer globalInitializer, string appName, bool isClientSideProgram, bool useRelativeInstallationPath = false, Func mainDataAccessStateGetter = null ) : void
globalInitializer SystemInitializer The system's global initializer. Do not pass null.
appName string
isClientSideProgram bool
useRelativeInstallationPath bool Pass true to use a relative path for the installation folder. This means that the folder will be located using /// the working directory rather than the assembly path. Use with caution.
mainDataAccessStateGetter Func A method that returns the current main data-access state whenever it is requested, including during this /// InitStatics call. Do not allow multiple threads to use the same state at the same time. If you pass null, the data-access subsystem will not be /// available in the application.
Résultat void
Exemple #1
0
        /// <summary>
        /// Call this from Application_Startup. Besides this call, there should be no other code in the method.
        /// </summary>
        /// <param name="globalInitializer">The system's global initializer. Do not pass null.</param>
        /// <param name="appInitializer">The application initializer, which performs application-specific initialization and cleanup. If you have one of these you
        /// should name the class AppInitializer.</param>
        public static void InitStatics(SystemInitializer globalInitializer, SystemInitializer appInitializer = null)
        {
            GlobalInitializationOps.InitStatics(globalInitializer, "Application", false);
            if (GlobalInitializationOps.SecondaryInitFailed)
            {
                shutDown();
                return;
            }
            exceptionHandlerEnabled = true;

            WpfInitializationOps.appInitializer = appInitializer;
            if (appInitializer != null)
            {
                appInitializer.InitStatics();
            }
        }
Exemple #2
0
        /// <summary>
        /// Call this from the SetUp method in your NUnit initializer. Besides this call, there should be no other code in the method.
        /// </summary>
        /// <param name="globalInitializer">The system's global initializer. Do not pass null.</param>
        /// <param name="appInitializer">The application initializer, which performs unit-testing-specific initialization and cleanup. If you have one of these you
        /// should name the class AppInitializer.</param>
        public static void InitStatics(SystemInitializer globalInitializer, SystemInitializer appInitializer = null)
        {
            GlobalInitializationOps.InitStatics(globalInitializer, "Tests", false, useRelativeInstallationPath: true);
            try {
                if (GlobalInitializationOps.SecondaryInitFailed)
                {
                    throw new ApplicationException(
                              "An exception occurred during application initialization. Details should be available in an error email and the installation's error log.");
                }

                UnitTestingInitializationOps.appInitializer = appInitializer;
                if (appInitializer != null)
                {
                    appInitializer.InitStatics();
                }
            }
            catch {
                CleanUpStatics();
                throw;
            }
        }