.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

IUriStreamService.RegisterProvider(IUriStreamProvider) Method

Registers the Uri data stream provider and makes it available to clients of the service.

Namespace: DevExpress.Office.Services

Assembly: DevExpress.Office.v21.1.Core.dll


void RegisterProvider(
    IUriStreamProvider provider


Name Type Description
provider IUriStreamProvider

An object which exposes the IUriStreamProvider interface.


Use the RegisterProvider method to add a custom provider object that is used by a IUriStreamService service to retrieve data from the specified URI.

To obtain the data stream from the URI encountered in the document (such as an inline image or a calculated field with the corresponding switch) the RichEditControl accesses the IUriStreamService. The service processes the URI with the help of registered URI stream providers.

This implementation enables you to create and register a custom URI Stream provider that is capable of processing a custom URI in a specific way, for example, to retrieve images for the INCLUDEPICTURE field from a database.

This example demonstrates how to use the IUriStreamService.RegisterProvider method to register a custom data stream provider implementing the IUriStreamProvider interface and make it available to clients of the IUriStreamService service.

private void RegisterUriStreamService(RichEditControl richEditControl) {
    IUriStreamService uriStreamService = richEditControl.GetService<IUriStreamService>();
    uriStreamService.RegisterProvider(new ImageStreamProvider(NorthwindDataProvider.Categories, "Picture"));

View Example: Use Images When Implementing Mail Merge

This example demonstrates how to implement the IUriStreamProvider interface to create a custom data stream provider for the IUriProviderService service.

public class ImageStreamProvider : IUriStreamProvider {
    static readonly string prefix = "dbimg://";
    DataTable table;
    string columnName;

    public ImageStreamProvider(DataTable sourceTable, string imageColumn) {
        this.table = sourceTable;
        this.columnName = imageColumn;

    public Stream GetStream(string uri) {
        uri = uri.Trim();
        if (!uri.StartsWith(prefix))
            return null;
        string strId = uri.Substring(prefix.Length).Trim();
        int id;
        if (!int.TryParse(strId, out id))
            return null;
        DataRow row = table.Rows.Find(id);
        if (row == null)
            return null;
        byte[] bytes = row[columnName] as byte[];
        if (bytes == null)
            return null;

        // Use this approach to trim the OLE header off the image
        // See also: https://supportcenter.devexpress.com/ticket/details/q233460/how-do-i-bind-a-pictureedit-to-sql-server-image-column, 
        // https://social.msdn.microsoft.com/Forums/en-US/c37289c7-3ca5-458e-8eda-286ffa2ff966/retrieving-an-image-from-a-table-in-a-c-picturebox?forum=sqldataaccess
        MemoryStream memoryStream = new MemoryStream();
        int oleHeaderOffset = 78;
        memoryStream.Write(bytes, oleHeaderOffset, bytes.Length - oleHeaderOffset);

        return memoryStream;
See Also