Skip to main content
All docs
V24.2

InvalidAccessException Class

An exception that can occur when you try to access an inaccessible API during a server-client transaction.

Namespace: DevExpress.Blazor.RichEdit

Assembly: DevExpress.Blazor.RichEdit.v24.2.dll

NuGet Package: DevExpress.Blazor.RichEdit

Declaration

public class InvalidAccessException :
    Exception

Remarks

The Rich Text Editor sends data from the server to the client every time you make changes to a document. Enclose your code in the BeginTransaction() - EndTransaction() method calls to lock the RichEdit’s data transmission to the client when you make multiple changes to a document. Such transactions allow you to send a batch of changes to the client and improve the component’s performance.

Each BeginTransaction() method call should be paired with the EndTransaction() method call. The BeginTransaction() method marks the starting point of a server-client transaction and locks the component to prevent constant data transmission. The EndTransaction() method unlocks the component and sends all accumulated changes to the client.

Run Demo: Document API

Invalid Access Exception

During transactions (batch document updates on the server), the Rich Text Editor operates with mock objects that do not exist on the client yet. As the result, some API members of these objects become inaccessible. If code enclosed in a transaction contains inaccessible APIs, the component throws an InvalidAccessException and displays the following error message:

The {propertyName}/{methodName} property/method is not accessible in the transaction.

The message text contains the name of the first inaccessible property/method found within the transaction.

async Task InitializeDocument() {
    Document documentAPI = richEdit.DocumentAPI;

    documentAPI.BeginTransaction();
    await CreateTitleParagraph(documentAPI);
    // ...
    await documentAPI.EndTransaction();
}

async Task CreateTitleParagraph(Document documentAPI) {
    Paragraph titleParagraph = await documentAPI.Paragraphs.CreateAsync(0);
    var alignment = titleParagraph.Alignment;
    // Alignment is an inaccessible property. When you attempt to access it, the following error message appears: 
    // "The Alignment property is not accessible in the transaction."
    ...
}

Access Properties

You cannot access an object’s properties during transactions, except in the following cases:

  • You use them in the corresponding ChangePropertiesAsync() method.
  • You use an object’s Interval property. Note that Interval class members are inaccessible.
  • You use a table’s Rows property (for tables declared in the same transaction). Note that the Rows property becomes inaccessible if you use it after a MergeCellsAsync or SplitAsync method call in the same server-client transaction.

Access Methods

During transactions, you cannot call methods that return collections of objects or do not return API objects:

Implements

Inheritance

Object
Exception
InvalidAccessException
See Also