|
Hi,
I have a main startup form called MainForm and I declared an instance of a class that launches a timers.timer that needs to update the MainForm controls (textboxes, progressBars,...) so I created the following delegate in MainForm:
Public Delegate Sub updateMainForm(ByRef neededChannel As Integer)
and the following call from the Timers.Timer.Elapsed event:
mainForm.Invoke(New mainForm.updateMainForm(AddressOf mainForm.determineIfKeepInAllOrIndividualChannel), New Object() {currentSTATE.CHANNEL})
and I get this error:
An error occurred creating the form. See Exception.InnerException for details. The error is: 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.
I looked into the error and they recommended putting a <STATThread>_ in the Main function but I don't have a main function. If there is a better way to communicate with the MainForm from the Elapsed event then that is fine as well. I'm looking into starting the Timer from a BackgroundThread and keep it alive with Monitor so that I can utilize both ProgressChanged and WorkCompleted, but there must be a simpler way.
|
|
|
|
|
Hi,
seems like you are using some component (a separate DLL?) that needs the thread to be STA.
(what are those channels?)
A Timers.Timer will fire on a separate Thread of which you don't have control.
The easiest fix might be to switch to a Windows.Forms.Timer, which ticks on the GUI thread,
which by default is STA IIRC.
|
|
|
|
|
I looked into the error details and it came out with this:
System.InvalidOperationException was unhandled by user code
Message="An error occurred creating the form. See Exception.InnerException for details. The error is: 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."
Source="ScienceProgram_v2"
StackTrace:
at ScienceProgram_v2.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190
at ScienceProgram_v2.My.MyProject.MyForms.get_mainForm()
at ScienceProgram_v2.startExperimentClass.STATUSupdate_MainForm() in G:\ProgrammingFolder\ScienceProgram\ScienceProgram_v2\neededClasses\startExperimentClass.vb:line 1229
at ScienceProgram_v2.startExperimentClass.endExperiment(Boolean& experimentCanceled) in G:\ProgrammingFolder\ScienceProgram\ScienceProgram_v2\neededClasses\startExperimentClass.vb:line 1190
at ScienceProgram_v2.startExperimentClass.sendCommands() in G:\ProgrammingFolder\ScienceProgram\ScienceProgram_v2\neededClasses\startExperimentClass.vb:line 1115
at ScienceProgram_v2.startExperimentClass.repeatingTimer_elapsed(Object source, ElapsedEventArgs e) in G:\ProgrammingFolder\ScienceProgram\ScienceProgram_v2\neededClasses\startExperimentClass.vb:line 1094
at System.Timers.Timer.MyTimerCallback(Object state)
InnerException: System.Threading.ThreadStateException
Message="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."
Source="System.Windows.Forms"
StackTrace:
at System.Windows.Forms.ComboBox.set_AutoCompleteSource(AutoCompleteSource value)
at ScienceProgram_v2.mainForm.InitializeComponent() in G:\ProgrammingFolder\ScienceProgram\ScienceProgram_v2\mainForm.Designer.vb:line 843
at ScienceProgram_v2.mainForm..ctor()
InnerException:
Maybe something here?
The only DLLs that I use are the Krypton Toolkit and the DevExpress Xtra editors. Everything else is standard Microsfot stuff.
-Max
modified on Monday, July 14, 2008 4:07 AM
|
|
|
|
|
When I open the admin form from the file menu of the main form then close the admin form and open it again I get a binding error.
Here is the error. Why am I getting the error?
This causes two bindings in the collection to bind to the same property.
Parameter name: binding
|
|
|
|
|
Since none of us have any idea what the admin form and main form are, perhaps you could provide us some more information. What code are you using to open and close these forms?
|
|
|
|
|
There is one thing that we cannot understand in your Situation, is because we dont see your code, and that means we dotn know what you are talking about, if you can show us your code it would be better
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Hi,
I am trying to read some system config from the registry. The config info is stored as a binary value of type "REG_RESOURCE_LIST".
If I try read this value with o=registrykey.getvalue(), (with o being an object), o will be set to nothing.
I can read a string key from the same group using the same command, and it works. It just always seems to fail on binary keys.
The "GetValueKind" of this key type returns Unknown.
Any idea what I am doing wrong? I've been googling for what seems like all morning, and I cant find a solution.
[Modified to sort out a typo]
|
|
|
|
|
Hi,
the RegistryValueKind Enumeration lists all data kinds supported by .NET, as well as Unknown for
all the other ones. So you're out of luck. I suggest you use P/Invoke and call the Win32 functions
directly (as was needed for all kinds other than REG_SZ before .NET 2.0).
|
|
|
|
|
I was hoping not to have to do that.
Oh hum.
Thanks for the reply - at least it puts my mind at rest that I have not gone crazy... (I am just slowly on my way to being there! )
Thanks.
|
|
|
|
|
You're welcome.
Jasey9 wrote: at least it puts my mind at rest that I have not gone crazy
I did not imply that, nor the opposite.
|
|
|
|
|
Hi,I am using vb.net to create an windows form application.
Does anyone know of any articles/ideas that could help me in adding textboxes or combo boxes to a listview?
Basically what i want to do is edit the data in the listview and it should save once i click out of it.
Thanks
Anoop
|
|
|
|
|
Have you googled or codeprojected? It seems like I've seen hundreds. In .NET 3.+, you can do it also through WPF.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
yep, i have googled it,
do you have an example in WPF?
thanks
|
|
|
|
|
I want to automatically send an email to customers on a set date. So if it is know in the database that the due date is July 11 2008 then the sql server has a schedule task … and it triggers a asp.net page to be run that sends the customer an email
Can someone please help me with this
Thank You
|
|
|
|
|
Write a vbscript to do what you want and use Windows Task Scheduler to schedule the script.
|
|
|
|
|
Schedule a Bat File
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Hello everyone,
I'm very new to VB6 and I've been blessed to be the fall-out boy for creating this system that SHOULD connect the application to SSH giving me control using UNIX functions. My question is...how do I make this possible. I'm pretty much clueless about this. Many many thanks for all your suggestions.
Aim small, miss small
|
|
|
|
|
You'll need a 3rd party component to handle the ssh connection. There's one at http://www.ssh-activex.com/[^] that has a free version available. I don't know what the limitations are in the free one.
|
|
|
|
|
Great! Exactly what I was looking for. Many thanks friend
Aim small, miss small
|
|
|
|
|
tatchung wrote: I'm very new to VB6
I feel sorry for you. VB6 has been dead/unsupported by Microsoft since March 2005. You may want to become more familiar with VB.NET/C#, just a friendly suggestion
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Paul Conrad wrote: I feel sorry for you
Indeed...
Paul Conrad wrote: You may want to become more familiar with VB.NET/C#
I'm actually quite familiar (but not near an expert) with .NET framework although management requires me to do this using crappy vb6. This app is actually like a trouble ticketing systems that allows certain users to display records, validate codes etc and provide resolutions. Problem is the records are not really database driven...rather file based using SSH. Yeah I know...problematic either way
Paul Conrad wrote: just a friendly suggestion
Many thanks for the concern. I greatly appreciate it
Aim small, miss small
|
|
|
|
|
tatchung wrote: management requires me to do this using crappy vb6
I really feel sorry for you, then.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Need to retrieve treeNodes during the pageload event. It should be built within for loop.how to write the code to find out which child belongs to which parent . i'm confused Whether sp can be written to get child for the parent or. for loop to be written to solve this problem. suggest me one idea.
spriya
|
|
|
|
|
Do you understnd what you Wrote?, Do you think someone can understand it? when you have a problem and you want to post it in the forum, make sure that you have tried something and post the code of what you have already done , and tell us where you got stuck and we will help you , we cannot do your job for you.
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Hello all,
I'm trying to help my sister do a simple window form application here for her grocery shop. I'm using Visual Studio .NET 2003 to create a Point Of Sales System for her shop.It is connected with MySQL 5.0 Database. I'm trying to doing a system planning and researching about this coding here.
Anyone can provide me some information or sample how can I detect a parallel receipt printer or barcode printer using VB.NET? I need this Window Form Application to detect the receipt printer,if the receipt printer is not turning on or plug into the workstation,it will prompup and request the user to check it.
Hope someone can help me on this problem. Thanks for reading.
Regards
Drexler
|
|
|
|