Skip to main content
All docs
V23.2

BindToTypePolicy.QueryNonTrustedTypeValidationEventArgs.TrustThisType(Boolean) Method

Specifies that the custom (“unknown”) type is “safe” and suppresses a security warning.

Namespace: DevExpress.Utils

Assembly: DevExpress.Data.v23.2.dll

NuGet Package: DevExpress.Data

Declaration

public void TrustThisType(
    bool doNotTrace = false
)

Optional Parameters

Name Type Default
doNotTrace Boolean False

Remarks

The following example validates custom data types:

using System;
using System.Windows.Forms;

namespace DXApplication {
    internal static class Program {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main() {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            DevExpress.Utils.BindToTypePolicy.QueryNonTrustedTypeValidation += BindToTypePolicy_QueryNonTrustedTypeValidation;
            Application.Run(new Form1());
        }
        private static void BindToTypePolicy_QueryNonTrustedTypeValidation(object sender, DevExpress.Utils.BindToTypePolicy.QueryNonTrustedTypeValidationEventArgs e) {
            if (e.IsUnsafe)
                throw new MyAppLicationSecurityException(e.AssemblyQualifiedTypeName);
            if (e.AssemblyName == typeof(Program).Assembly.FullName)
                e.TrustThisType();
            if (e.TypeName == "ObsoleteJsonDataSource")
                e.DoNotTrustThisType();
        }
    }
}
See Also