eXpandFramework / eXpand

DevExpress XAF (eXpressApp) extension framework. 𝗹𝗶𝗻𝗸𝗲𝗱𝗶𝗻.𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸.𝗰𝗼𝗺, 𝘆𝗼𝘂𝘁𝘂𝗯𝗲.𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸.𝗰𝗼𝗺 and 𝘁𝘄𝗶𝘁𝘁𝗲𝗿 @𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸 and or simply 𝗦𝘁𝗮𝗿/𝘄𝗮𝘁𝗰𝗵 this repository and get notified from 𝗚𝗶𝘁𝗛𝘂𝗯
http://expand.expandframework.com
Microsoft Public License
220 stars 114 forks source link

ExcelImporter module show error -Reentrancy or cross thread operation detected #1020

Closed txt2203 closed 6 months ago

txt2203 commented 1 year ago

𝗗𝗲𝘀𝗰𝗿𝗶𝗯𝗲 𝘁𝗵𝗲 𝗯𝘂𝗴 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

apobekiaris commented 1 year ago

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);
txt2203 commented 12 months ago

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(); builder.Modules .Add() .Add(); 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);

}

expand commented 6 months ago

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

.Thank you for your contribution.