blazor-devexpress-dot-blazor-dot-richedit-5a18916a.md
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.v25.2.dll
NuGet Package : DevExpress.Blazor.RichEdit
public class InvalidAccessException :
Exception
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.
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."
...
}
You cannot access an object’s properties during transactions, except in the following cases:
ChangePropertiesAsync() method.During transactions, you cannot call methods that return collections of objects or do not return API objects:
Object Exception InvalidAccessException
See Also