Back to Devexpress

EFDataSource.BeforeLoadCustomAssemblyGlobal Event

corelibraries-devexpress-dot-dataaccess-dot-entityframework-dot-efdatasource-012bc339.md

latest5.6 KB
Original Source

EFDataSource.BeforeLoadCustomAssemblyGlobal Event

Occurs on an attempt to load a custom assembly by EFDataSource (e.g., when an application loads a report template containing an Entity Framework data source originated from a compiled assembly).

Namespace : DevExpress.DataAccess.EntityFramework

Assembly : DevExpress.DataAccess.v25.2.dll

NuGet Package : DevExpress.DataAccess

Declaration

csharp
public static event BeforeLoadCustomAssemblyEventHandler BeforeLoadCustomAssemblyGlobal
vb
Public Shared Event BeforeLoadCustomAssemblyGlobal As BeforeLoadCustomAssemblyEventHandler

Event Data

The BeforeLoadCustomAssemblyGlobal event's data class is BeforeLoadCustomAssemblyEventArgs. The following properties provide information specific to this event:

PropertyDescription
AllowLoadingSpecifies whether loading a custom assembly is allowed.
AssemblyPathSpecifies the path to a requested assembly.
ContextNameSpecifies the type to load from a custom assembly.

Remarks

Loading of custom assemblies that may be referenced by Entity Framework data sources is forbidden by default.

To permit loading a specific assembly, handle the EFDataSource.BeforeLoadCustomAssembly event (or static BeforeLoadCustomAssemblyGlobal event) and specify the following properties of the BeforeLoadCustomAssemblyEventArgs object.

An unauthorized attempt to load a custom assembly will result in throwing a CustomAssemblyLoadingProhibitedException.

In the Data Source wizard, the corresponding option is disabled so that end-users are only allowed to select a data context from assemblies referenced by the project.

To make the Browse button visible, set the EFWizardSettings.ShowBrowseButton property to true.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the BeforeLoadCustomAssemblyGlobal event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

reporting-wpf-designer-load-custom-assembly/CS/MainWindow.xaml.cs#L12

csharp
InitializeComponent();
    EFDataSource.BeforeLoadCustomAssemblyGlobal += OnBeforeCustomAssemblyLoad;
}

reporting-wpf-designer-load-custom-assembly/VB/MainWindow.xaml.vb#L14

vb
InitializeComponent()
    AddHandler EFDataSource.BeforeLoadCustomAssemblyGlobal, AddressOf OnBeforeCustomAssemblyLoad
End Sub

See Also

BeforeLoadCustomAssembly

Data Access Security in WinForms Applications

EFDataSource Class

EFDataSource Members

DevExpress.DataAccess.EntityFramework Namespace