Skip to main content
All docs
V25.1
  • EnvironmentPolicy.ThrowOnErrors() Method

    Throws an exception if a request to System.Environment fails.

    Namespace: DevExpress.Data.Utils

    Assembly: DevExpress.Data.v25.1.dll

    NuGet Package: DevExpress.Data

    Declaration

    public static void ThrowOnErrors()

    Remarks

    Call the ThrowOnErrors method at application startup to throw an exception if a request to System.Environment fails. Handle the Failed event to trace and respond to associated failures.

    using System;
    using System.Windows.Forms;
    
    namespace EnvironmentPolicyDemo {
        internal static class Program {
            /// <summary>
            /// The main entry point for the application.
            /// </summary>
            [STAThread]
            static void Main() {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                DevExpress.Data.Utils.EnvironmentPolicy.ThrowOnErrors();
                DevExpress.Data.Utils.EnvironmentPolicy.Failed += EnvironmentPolicy_Failed;
                Application.Run(new Form1());
            }
    
            static void EnvironmentPolicy_Failed(object sender, DevExpress.Data.Utils.EnvironmentPolicy.FailedEventArgs e) {
                Console.WriteLine(e.Exception.Message);
                e.Throw = false;
            }
        }
    }
    

    Tip

    Read the following topic for additional information: Environment Policy.

    See Also