eXpand icon indicating copy to clipboard operation
eXpand copied to clipboard

ExcelImporter module show error -Reentrancy or cross thread operation detected

Open txt2203 opened this issue 2 years ago • 2 comments

𝗗𝗲𝘀𝗰𝗿𝗶𝗯𝗲 𝘁𝗵𝗲 𝗯𝘂𝗴 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. Screenshot 2023-09-09 075138 err.txt

txt2203 avatar Sep 09 '23 01:09 txt2203

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);

apobekiaris avatar Sep 09 '23 04:09 apobekiaris

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);

}

txt2203 avatar Sep 10 '23 18:09 txt2203

Closing issue for age. Feel free to reopen it at any time.

.Thank you for your contribution.

expand avatar Feb 26 '24 21:02 expand