DrawingModuleInitialize Method

KGy SOFT Drawing Libraries Help
Initializes the KGySoft.Drawing module. On non-Windows platforms it makes possible to use System.Drawing types without editing the runtimeconfig.json file. Additionally, it initializes the resource manager for string resources and registers its central management in the LanguageSettings class.
See the Remarks section for details.

Namespace:  KGySoft.Drawing
Assembly:  KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 6.0.0

public static void Initialize()

Note Note
The module initializer is executed automatically when any member is accessed in the module for the first time. This method is public to able to trigger module initialization without performing any other operation. Normally you don't need to call it explicitly but it can be useful if you use the KGy SOFT Drawing Libraries in an application and you want to configure resource management on starting the application via the LanguageSettings class. In such case you can call this method before configuring language settings to make sure that the resources of the KGySoft.Drawing.dll are also affected by the settings.
Important note Important
If you use KGy SOFT Drawing Libraries from a non-Windows application, then make sure you call this method before using any System.Drawing type to prevent a TypeInitializationException without editing the runtimeconfig.json file. It is not necessary if you reference the .NET Framework build under Mono.

The following example demonstrates how to initialize the KGySoft.Drawing module in an application (you don't really need to do this if you use KGy SOFT Drawing Libraries from a class library):
using KGySoft;
using KGySoft.Drawing;
using KGySoft.Resources;

public class Example
    public static void Main()
        // To make sure that configuring LanguageSettings affects also the resources in KGySoft.Drawing
        // For non-Windows applications it also enables using System.Drawing types

        // Opting in to use compiled and .resx resources for the application
        LanguageSettings.DynamicResourceManagersSource = ResourceManagerSources.CompiledAndResX;
        LanguageSettings.DisplayLanguage = MyConfigs.GetLastlyUsedLanguage(); // Get some CultureInfo

        // Optional: To add possibly new resource entries to the localization of the current language

        // Now you can launch the actual application
        LaunchMyApplication(); // whatever your app actually does
See Also