473,785 Members | 3,349 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on

Joe
I've been getting this message at all different times since a few days ago.
I understand the message but not why I get it. I don't have any other
threads.

This happens when closing dialog boxes, doing a drag and drop and a few
other things which I don't remember right now.
It only happens while I'm running within the IDE and only seems to be on my
computer. We've tested the same thing on other machines running VS.2005 and
there is no problem.

Any ideas? I'm thinking I need to reinstall VS.

Thanks,
Joe
Mar 3 '07 #1
6 32247
Hello joe.

Reinstalling VS wont solve the problem.
The problem you are facing is because microsoft finally decided to
enforce strict restriction on cross thread acces of control..(i.e you
cannot acces the control from other threads than on which it was
created on)
There are two solutions for this..
1The lengthy and the better solution ..
Using the InvokeRequired property of the control.
Eg.
private void Form1_Load(obje ct sender, EventArgs e)
{
if(InvokeRequir ed)
{
this.Invoke(new EventHandler(Fo rm1_Load), new object[]
{sender, e});
return;
}
//Your code here...
}

2>
Just set the Control.CheckFo rIllegalCrossTh readCalls property to
false.
This willstop the exception being thrown but wont solve the problem.
I would recommend the first way.
Mar 3 '07 #2
Hi Joe ,

Amar has provided the detailed correct reply to you.

Note: Microsoft enforces this restriction to help us to detect the invalid
operation: accessing the UI control methods/properties from another thread.
This is the GUI threading rule, which is introduced by history reason(.Net
Winform controls encapsulates Win32 controls which are COM STA threading
model. This threading model requires the accessing to the controls can only
be allowed from the creating thread).

So the first solution is highly recommended and second way is turning off
the Microsoft's help.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 5 '07 #3
Joe
Hi Amar,

I do not have any other threads in this application which could cause the
problem. We don't use BeginInvoke, ThreadPool or new Thread.

Like I said this just happened out of no where.

-Joe

"Amar" <am************ **@gmail.comwro te in message
news:11******** *************@j 27g2000cwj.goog legroups.com...
Hello joe.

Reinstalling VS wont solve the problem.
The problem you are facing is because microsoft finally decided to
enforce strict restriction on cross thread acces of control..(i.e you
cannot acces the control from other threads than on which it was
created on)
There are two solutions for this..
1The lengthy and the better solution ..
Using the InvokeRequired property of the control.
Eg.
private void Form1_Load(obje ct sender, EventArgs e)
{
if(InvokeRequir ed)
{
this.Invoke(new EventHandler(Fo rm1_Load), new object[]
{sender, e});
return;
}
//Your code here...
}

2>
Just set the Control.CheckFo rIllegalCrossTh readCalls property to
false.
This willstop the exception being thrown but wont solve the problem.
I would recommend the first way.


Mar 5 '07 #4
"Joe" <jb*******@noem ail.noemailwrot e in message
news:eO******** ******@TK2MSFTN GP02.phx.gbl...
Hi Amar,

I do not have any other threads in this application which could cause the problem. We
don't use BeginInvoke, ThreadPool or new Thread.

Like I said this just happened out of no where.
This message only shows up when running a debug version!
Are you sure your Main entry is marked [STAThread]?

Willy.

Mar 5 '07 #5
Hi Joe,

Sorry, it seems that we missed your "I don't have any other threads"
statement in the first post.

After giving a detailed reading to your post, I see you stated "It only
happens while I'm running within the IDE and only seems to be on my
computer".

Does this mean this error only displays while you are debugging it with
VS2005 or just press Ctrl+F5 to launch it from IDE? Do you use "Debug" or
"Release" configuration?

Do you mean if you moved this project to another machine, the problem will
not arise?

In this situation, while the exception is generated under VS2005 debugg, it
would be informative to examine the following 2 places:
1. Open "Threads" window to examine how many threads are there during the
exception and which thread is throwing this exception.
2. Open "Call Stack" window to determine the stack trace of this exception.

Note: to get the accurate stack trace, you may need to set the symbol path
correctly. To set the symbol server path in VS2005, you should input
"srv*c:\LocalSy mbols*http://msdl.microsoft. com/download/symbols;" in the
Tools | Options | Debugging | Symbols as the directory. This will tell the
VS2005 debugger to lookup symbol from the Microsoft symbol server
"http://msdl.microsoft. com/download/symbols" and cache the downloaded
symbol in "c:\LocalSymbol s" folder.

Additionally, there is a new feature named "Just My Code" which is enabled
by default in VS2005. This means that VS2005 will not load symbol for
non-user code assemblies, such as all .Net BCL assemblies. So you should
disable this "Just My Code" feature from Tools | Options | Debugging, and
uncheck "Enable Just My Code" check box.(the VS2005 IDE maybe need
close&re-open to enable the setting)

Below link contains more information regarding JMC feature:
"Is 'Just my Code' for you?"
http://blogs.msdn.com/greggm/archive...29/201315.aspx

To verify if the above 2 settings take effect, you may open "Module" window
after launching the application under debugger.

Note: symbol loading may require some time after you pressed F5, you may
check the "Output" window to verify the symbol loading process for each
modules.

Please paste above 2 windows information here so that we can give it an
analysis. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 6 '07 #6
Hi Joe,

How about this issue now?

Have you reviewed my last reply to you? Have you managed to collect the
stack trace information regarding this error? If you still need any help or
have any concern, please feel free to tell me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 12 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2055
by: Web Science | last post by:
Site and Features: http://www.eigensearch.com Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics, manifolds, science, physics, chemistry, law, legal, government, home, office, business, domain lookup, medical, travel, food, university students, searching, searchers, surfing, advanced search, search tools Chemistry, mathematics, physical sciences,...
12
3880
by: * ProteanThread * | last post by:
but depends upon the clique: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=954drf%24oca%241%40agate.berkeley.edu&rnum=2&prev=/groups%3Fq%3D%2522cross%2Bposting%2Bversus%2Bmulti%2Bposting%2522%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den ...
0
1894
by: Web Science | last post by:
Site and Features: http://www.eigensearch.com Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics, manifolds, science, physics, chemistry, law, legal, government, home, office, business, domain lookup, medical, travel, food, university students, searching, searchers, surfing, advanced search, search tools Chemistry, mathematics, physical sciences,...
4
5584
by: David Peach | last post by:
Hello, hope somebody here can help me... I have a query that lists defects recorded in a user defined date range. That query is then used as the source for a Cross Tab query that cross-tabs count of defect type by calendar month. Defect types are stored in one table, defect transactions in another along with date etc. When I cross-tab the results, defect types that have no defects recorded against them appear as a blank (null) value. That...
0
2059
by: Web Science | last post by:
Site and Features: http://www.eigensearch.com Search engine, eigenMethod, eigenvector, mathematical, manifolds, science, technical, search tools, eigenmath, Jacobian, quantum, mechanics, manifolds, science, physics, chemistry, law, legal, government, home, office, business, domain lookup, medical, travel, food, university students, searching, searchers, surfing, advanced search, search tools Chemistry, mathematics, physical sciences,...
6
13165
by: Robert Bravery | last post by:
Hi all, Can some one show me how to achieve a cross product of arrays. So that if I had two arrays (could be any number) with three elements in each (once again could be any number) I would get: the two arrays {"one","two","three"},{"red","green","blue} the result one red one green
7
2638
by: Charles | last post by:
I'd like to develop a simple cross-platform application in C++. I'd like it to run in Windows, OS X, PC-BSD and Linux. From my research, it seems I should use Qt or Gtk as a graphical library. Do you agree? Do you have other tips? How Cygwin could help me? Thanks.
6
8635
by: Simon | last post by:
Hi All, An experiment i'm doing requires requires a synchronous cross-domain request, without using a proxy. I wondered if anyone had any ideas to help me achieve this. Below is what I have tried, including my conclusions/assumptions (which i'll happily be corrected on if it solves my problem!): The requirement not to use a proxy means I can't use the synchronous
6
5483
by: Bart Van der Donck | last post by:
Hello, I'm presenting my new library 'AJAX Cross Domain' - a javascript extension that allows to perform cross-domain AJAX requests. http://www.ajax-cross-domain.com/ Any comments or suggestions are welcome. --
6
3992
by: ampo | last post by:
Hello. Can anyone help with cross-domain problem? I have HTML page from server1 that send xmlHTTPRequest to server2. How can I do it? Thanks.
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9947
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.