We have a client agnostic module setup to provide a custom ObjectSpaceProvider and I have set it it to thread safe, but still get the cross-thread access error when I run a command using RunCmd. I have an older multithreaded that is using the DevExpress Server Application. below is most of the Module.cs file from the module that's being used as the base for the RunCmds. public sealed partial class PortalXafariServerModule : ModuleBase, ICommandEnumerator { private SecurityStrategyComplex securityStrategyComplex; private XafariAuthentication authentication; public PortalXafariServerModule() { InitializeComponent(); BaseObject.OidInitializationMode = OidInitializationMode.AfterConstruction; authentication = new XafariAuthentication(); securityStrategyComplex = new SecurityStrategyComplex(); authentication.AuthenticationActiveDirectory.CreateUserAutomatically = true; authentication.AuthenticationActiveDirectory.LogonParametersType = typeof(XafariAuthenticationLogonParameters); authentication.AuthenticationStandard.LogonParametersType = typeof(XafariAuthenticationLogonParameters); authentication.LogonParametersType = typeof(XafariAuthenticationLogonParameters); securityStrategyComplex = new SecurityStrategyComplex(typeof(Portal.Data.Security.User), typeof(Portal.Data.Security.Role), authentication); } public override void Setup(XafApplication application) { base.Setup(application); application.DelayedViewItemsInitialization = true; application.Security = securityStrategyComplex; var appName = System.Configuration.ConfigurationManager.AppSettings["ApplicationName"]; if (!string.IsNullOrEmpty(appName)) application.ApplicationName = appName; application.CreateCustomObjectSpaceProvider += Application_CreateCustomObjectSpaceProvider; application.CustomizeFormattingCulture += Application_CustomizeFormattingCulture; application.CustomizeLanguagesList += application_CustomizeLanguagesList; application.DatabaseVersionMismatch += application_DatabaseVersionMismatch; application.SetupComplete += application_SetupComplete; application.DatabaseUpdateMode = DevExpress.ExpressApp.DatabaseUpdateMode.Never; } private void Application_CustomizeFormattingCulture(object sender, CustomizeFormattingCultureEventArgs e) { e.FormattingCulture.DateTimeFormat = CultureSettingsHelper.GetWeekStartingToMondayDateTimeFormat(); } private void Application_CreateCustomObjectSpaceProvider(object sender, CreateCustomObjectSpaceProviderEventArgs e) { if (e.ObjectSpaceProvider == null) { var app = (XafApplication)sender; //Seems to not use this in the application. e.ObjectSpaceProvider = new DevExpress.ExpressApp.Security.ClientServer.SecuredObjectSpaceProvider((SecurityStrategy)app.Security, e.ConnectionString, e.Connection,true); } } private void application_CustomizeLanguagesList(object sender, CustomizeLanguagesListEventArgs e) { string userLanguageName = System.Threading.Thread.CurrentThread.CurrentUICulture.Name; if (userLanguageName != "en-US" && e.Languages.IndexOf(userLanguageName) == -1) { e.Languages.Add(userLanguageName); } } ... } |