STA issue with DataGridView

Archived support forum for customers who once purchased a PrimalForms product license. This forum is locked.
This topic is 14 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
Xenophane
Posts: 29
Last visit: Wed Feb 03, 2021 3:59 am

STA issue with DataGridView

Post by Xenophane »

I am using the DataGridView object in one of my scripts in PrimalForms 2009, but I am getting a Single Thread Apartment (STA) error when I try to copy data from the grid when the script is running. When I try to do ctrl-c I get a .Net runtime warning saying, that in order to do OLE calls the current thread must be set to STA, I know this is possible to do, is it possible the add the option to PrimalForms as well ?I am running on Vista x64, .Net 3.5 SP1, PowerShell 2.0 RCSee the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.************** Exception Text **************System.Threading.ThreadStateException: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. at System.Windows.Forms.Clipboard.SetDataObject(Object data, Boolean copy, Int32 retryTimes, Int32 retryDelay) at System.Windows.Forms.DataGridView.ProcessInsertKey(Keys keyData) at System.Windows.Forms.DataGridView.ProcessDataGridViewKey(KeyEventArgs e) at System.Windows.Forms.DataGridView.OnKeyDown(KeyEventArgs e) at System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m) at System.Windows.Forms.DataGridView.ProcessKeyEventArgs(Message& m) at System.Windows.Forms.Control.ProcessKeyMessage(Message& m) at System.Windows.Forms.Control.WmKeyChar(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.DataGridView.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)************** Loaded Assemblies **************mscorlib Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000) CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll----------------------------------------PrimalForms Assembly Version: 1.0.0.0 Win32 Version: 1.0.1.0 CodeBase: file:///C:/Program%20Files%20(x86)/SAPIEN%20Technologies,%20Inc/PrimalForms%202009/PrimalForms.exe----------------------------------------System.Windows.Forms Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll----------------------------------------System Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll----------------------------------------System.Drawing Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll----------------------------------------BCGSoft.ControlBars.Ribbon Assembly Version: 4.0.10000.0 Win32 Version: CodeBase: file:///C:/Program%20Files%20(x86)/SAPIEN%20Technologies,%20Inc/PrimalForms%202009/BCGSoft.ControlBars.Ribbon.DLL----------------------------------------ActiproSoftware.SyntaxEditor.Net20 Assembly Version: 4.0.281.0 Win32 Version: 4.0.281.0 CodeBase: file:///C:/Program%20Files%20(x86)/SAPIEN%20Technologies,%20Inc/PrimalForms%202009/ActiproSoftware.SyntaxEditor.Net20.DLL----------------------------------------ActiproSoftware.Shared.Net20 Assembly Version: 1.0.101.0 Win32 Version: 1.0.101.0 CodeBase: file:///C:/Program%20Files%20(x86)/SAPIEN%20Technologies,%20Inc/PrimalForms%202009/ActiproSoftware.Shared.Net20.DLL----------------------------------------BCGSoft.ControlBars Assembly Version: 4.0.10000.0 Win32 Version: CodeBase: file:///C:/Program%20Files%20(x86)/SAPIEN%20Technologies,%20Inc/PrimalForms%202009/BCGSoft.ControlBars.DLL----------------------------------------BCGSoft.Controls.Shared Assembly Version: 4.0.10000.0 Win32 Version: CodeBase: file:///C:/Program%20Files%20(x86)/SAPIEN%20Technologies,%20Inc/PrimalForms%202009/BCGSoft.Controls.Shared.DLL----------------------------------------BCGSoft.Visualization Assembly Version: 4.0.10000.0 Win32 Version: CodeBase: file:///C:/Program%20Files%20(x86)/SAPIEN%20Technologies,%20Inc/PrimalForms%202009/BCGSoft.Visualization.DLL----------------------------------------BCGSoft.Shared Assembly Version: 4.0.10000.0 Win32 Version: CodeBase: file:///C:/Program%20Files%20(x86)/SAPIEN%20Technologies,%20Inc/PrimalForms%202009/BCGSoft.Shared.DLL----------------------------------------BCGSoft.Controls.TabStrip Assembly Version: 4.0.10000.0 Win32 Version: CodeBase: file:///C:/Program%20Files%20(x86)/SAPIEN%20Technologies,%20Inc/PrimalForms%202009/BCGSoft.Controls.TabStrip.DLL----------------------------------------ActiproSoftware.WinUICore.Net20 Assembly Version: 1.0.101.0 Win32 Version: 1.0.101.0 CodeBase: file:///C:/Program%20Files%20(x86)/SAPIEN%20Technologies,%20Inc/PrimalForms%202009/ActiproSoftware.WinUICore.Net20.DLL----------------------------------------BCGSoft.Design.Shared Assembly Version: 4.0.10000.0 Win32 Version: 4.0.10000.0 CodeBase: file:///C:/Program%20Files%20(x86)/SAPIEN%20Technologies,%20Inc/PrimalForms%202009/BCGSoft.Design.Shared.DLL----------------------------------------BCGSoft.Shared.LicManager Assembly Version: 4.0.10000.0 Win32 Version: CodeBase: file:///C:/Program%20Files%20(x86)/SAPIEN%20Technologies,%20Inc/PrimalForms%202009/BCGSoft.Shared.LicManager.DLL----------------------------------------System.Xml Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll----------------------------------------System.Data Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000) CodeBase: file:///C:/Windows/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll----------------------------------------System.Design Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Design/2.0.0.0__b03f5f7f11d50a3a/System.Design.dll----------------------------------------BCGSoft.Shared.Localization Assembly Version: 4.0.10000.0 Win32 Version: 4.0.10000.0 CodeBase: file:///C:/Program%20Files%20(x86)/SAPIEN%20Technologies,%20Inc/PrimalForms%202009/BCGSoft.Shared.Localization.DLL----------------------------------------BCGSoft.Visualization.Style.Obsidian Assembly Version: 4.0.10000.0 Win32 Version: 4.0.10000.0 CodeBase: file:///C:/Program%20Files%20(x86)/SAPIEN%20Technologies,%20Inc/PrimalForms%202009/BCGSoft.Visualization.Style.Obsidian.DLL----------------------------------------System.Runtime.Serialization.Formatters.Soap Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Runtime.Serialization.Formatters.Soap/2.0.0.0__b03f5f7f11d50a3a/System.Runtime.Serialization.Formatters.Soap.dll----------------------------------------PWSHHelpCtrl Assembly Version: 2.0.10.0 Win32 Version: 2.0.10.0 CodeBase: file:///C:/Program%20Files%20(x86)/SAPIEN%20Technologies,%20Inc/PrimalForms%202009/PWSHHelpCtrl.DLL----------------------------------------System.Management.Automation Assembly Version: 1.0.0.0 Win32 Version: 7.0.6002.18111 CodeBase: file:///C:/
Windows/assembly/GAC_MSIL/System.Management.Automation/1.0.0.0__31bf3856ad364e35/System.Management.Automation.dll----------------------------------------Microsoft.PowerShell.Commands.Diagnostics Assembly Version: 1.0.0.0 Win32 Version: 6.1.7600.16385 CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.PowerShell.Commands.Diagnostics/1.0.0.0__31bf3856ad364e35/Microsoft.PowerShell.Commands.Diagnostics.dll----------------------------------------System.Core Assembly Version: 3.5.0.0 Win32 Version: 3.5.30729.1 built by: SP CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Core/3.5.0.0__b77a5c561934e089/System.Core.dll----------------------------------------System.Configuration.Install Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration.Install/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.Install.dll----------------------------------------Microsoft.WSMan.Management Assembly Version: 1.0.0.0 Win32 Version: 7.0.6002.18111 CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.WSMan.Management/1.0.0.0__31bf3856ad364e35/Microsoft.WSMan.Management.dll----------------------------------------System.Transactions Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000) CodeBase: file:///C:/Windows/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll----------------------------------------Microsoft.PowerShell.Commands.Utility Assembly Version: 1.0.0.0 Win32 Version: 7.0.6002.18111 CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.PowerShell.Commands.Utility/1.0.0.0__31bf3856ad364e35/Microsoft.PowerShell.Commands.Utility.dll----------------------------------------Microsoft.PowerShell.ConsoleHost Assembly Version: 1.0.0.0 Win32 Version: 7.0.6002.18111 CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.PowerShell.ConsoleHost/1.0.0.0__31bf3856ad364e35/Microsoft.PowerShell.ConsoleHost.dll----------------------------------------Microsoft.PowerShell.Commands.Management Assembly Version: 1.0.0.0 Win32 Version: 7.0.6002.18111 CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.PowerShell.Commands.Management/1.0.0.0__31bf3856ad364e35/Microsoft.PowerShell.Commands.Management.dll----------------------------------------Microsoft.PowerShell.Security Assembly Version: 1.0.0.0 Win32 Version: 7.0.6002.18111 CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.PowerShell.Security/1.0.0.0__31bf3856ad364e35/Microsoft.PowerShell.Security.dll----------------------------------------System.Management Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Management/2.0.0.0__b03f5f7f11d50a3a/System.Management.dll----------------------------------------System.DirectoryServices Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.DirectoryServices/2.0.0.0__b03f5f7f11d50a3a/System.DirectoryServices.dll----------------------------------------Microsoft.WSMan.Runtime Assembly Version: 1.0.0.0 Win32 Version: 7.0.6002.18111 CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.WSMan.Runtime/1.0.0.0__31bf3856ad364e35/Microsoft.WSMan.Runtime.dll----------------------------------------System.ServiceProcess Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.ServiceProcess/2.0.0.0__b03f5f7f11d50a3a/System.ServiceProcess.dll----------------------------------------Accessibility Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll----------------------------------------System.Drawing.Design Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing.Design/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.Design.dll----------------------------------------System.Configuration Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000) CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll----------------------------------------System.EnterpriseServices Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000) CodeBase: file:///C:/Windows/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll----------------------------------------************** JIT Debugging **************To enable just-in-time (JIT) debugging, the .config file for thisapplication or computer (machine.config) must have thejitDebugging value set in the system.windows.forms section.The application must also be compiled with debuggingenabled.For example:<configuration> <system.windows.forms jitDebugging="true" /></configuration>When JIT debugging is enabled, any unhandled exceptionwill be sent to the JIT debugger registered on the computerrather than be handled by this dialog box.
Xenophane2009-08-17 03:03:03
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

STA issue with DataGridView

Post by Alexander Riedel »

The packaged script runs in a host that has STA set by default. Have you tried that?

Alex
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
Xenophane
Posts: 29
Last visit: Wed Feb 03, 2021 3:59 am

STA issue with DataGridView

Post by Xenophane »

No I have not.. I will test that right away.
User avatar
Xenophane
Posts: 29
Last visit: Wed Feb 03, 2021 3:59 am

STA issue with DataGridView

Post by Xenophane »

Just tried creating 4 packages one for each platform available in the packager, and I get the STA error in each of them.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

STA issue with DataGridView

Post by Alexander Riedel »

Ok, the main thread has the STA attribute, so I guess we will have to look deeper.

Alex
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
Xenophane
Posts: 29
Last visit: Wed Feb 03, 2021 3:59 am

STA issue with DataGridView

Post by Xenophane »

Just for info:I have just tested this with PowerShell ISE, I copied the code from Primalforms. That seems to work fine..Copying the code to PowerGUI or PrimalScript 2009 result in the same error.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

STA issue with DataGridView

Post by Alexander Riedel »

I think I have located the issue. We will need to provide
a specific STA host for packages.
Our dev team will look into what we can do for running it from within PrimalForms itself.

Alex
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
Xenophane
Posts: 29
Last visit: Wed Feb 03, 2021 3:59 am

STA issue with DataGridView

Post by Xenophane »

Don't worry I don't need it until after lunch :)Just kiddingXenophane2009-08-17 02:59:08
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

STA issue with DataGridView

Post by Alexander Riedel »

LOL. It's always lunch time somewhere on the planet....
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
ryanba
Posts: 28
Last visit: Tue Feb 23, 2010 11:27 pm

STA issue with DataGridView

Post by ryanba »

I am having the same issue with DataGrid and DataGridView. Has a resolution to error been found as I need to use DataGridViews in an application that I am developing?
This topic is 14 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.