eXpand
eXpand copied to clipboard
ExcelImporter module show error -Reentrancy or cross thread operation detected
𝗗𝗲𝘀𝗰𝗿𝗶𝗯𝗲 𝘁𝗵𝗲 𝗯𝘂𝗴 I made simple project XAF Winform .NET6 and use module ExcelImporter. After import files, file content and add Keymap, I run "Import", but it show: Reentrancy or cross thread operation detected. Use ThreadSafeDataLayer or find the cause of the cross thread access to the SimpleDataLayer instance from your code as described in https://www.devexpress.com/kb=T419520. To suppress this exception, set DevExpress.Xpo.SimpleDataLayer.SuppressReentrancyAndThreadSafetyCheck = true
𝗧𝗼 𝗥𝗲𝗽𝗿𝗼𝗱𝘂𝗰𝗲
Make a simple XAF Winform .NET6 . Add module ExcelImporter. Run. Add File, Keymap.
For Excel file with only several rows, it imports OK.
For >~1000 rows, above error appears.
err.txt
This is an XPO exception and should go away once you use a ThreadSafeDataleyr
e.g.
args.ObjectSpaceProvider=new SecuredObjectSpaceProvider((ISelectDataSecurityProvider) Security, new ConnectionStringDataStoreProvider(args.ConnectionString), true);
In Startup.cs of Winform project, I added "options.ThreadSafe = true;" then the program and module ExcelImporter ran normally. public class ApplicationBuilder: IDesignTimeApplicationFactory { public static WinApplication BuildApplication(string connectionString) { var builder = WinApplication.CreateBuilder(); builder.UseApplication<xxxxWindowsFormsApplication>(); builder.Modules .Add<xxxx.Module.xxxxModule>() .Add<xxxxModule>(); builder.ObjectSpaceProviders .AddSecuredXpo((application, options) => { options.ConnectionString = connectionString; options.ThreadSafe = true; //add this code to prevent err: Reentrancy or cross-thread operation detected }) .AddNonPersistent(); builder.Security .UseIntegratedMode(options => { options.RoleType = typeof(PermissionPolicyRole); options.UserType = typeof(xxxx.Module.BusinessObjects.ApplicationUser); options.UserLoginInfoType = typeof(xxxx.Module.BusinessObjects.ApplicationUserLoginInfo); options.UseXpoPermissionsCaching(); }) .UsePasswordAuthentication(); builder.AddBuildStep(application => { application.ConnectionString = connectionString; #if DEBUG if(System.Diagnostics.Debugger.IsAttached && application.CheckCompatibilityType == CheckCompatibilityType.DatabaseSchema) { application.DatabaseUpdateMode = DatabaseUpdateMode.UpdateDatabaseAlways; } #endif }); var winApplication = builder.Build(); return winApplication; }
XafApplication IDesignTimeApplicationFactory.Create()
=> BuildApplication(XafApplication.DesignTimeConnectionString);
}
Closing issue for age. Feel free to reopen it at any time.
.Thank you for your contribution.