DrawingModuleInitialize Method

Initializes the KGySoft.Drawing module (and also the KGySoft.Drawing.Core module). It initializes the resource manager for string resources and registers its central management in the LanguageSettings class.


Namespace: KGySoft.Drawing
Assembly: KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 8.1.0
public static void Initialize()



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.


If you target .NET 5 or 6 and 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. When targeting .NET 7 or later, this package can be used only on Windows. You can use the KGySoft.Drawing.Common package on all platforms though.


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 in .NET 5 and 6 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