473,796 Members | 2,465 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RichTextBox access error ?

Hello
I have some Threads, and they write something to
RichTextBox.Tex t property. But sometimes i receive error:

************** Exception Text **************
System.NullRefe renceException: Object reference not set to an instance
of an object.
at System.Windows. Forms.RichTextB ox.EditStreamPr oc(IntPtr dwCookie,
IntPtr buf, Int32 cb, Int32& transferred)
at System.Windows. Forms.UnsafeNat iveMethods.Call WindowProc(IntP tr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows. Forms.NativeWin dow.DefWndProc( Message& m)
at System.Windows. Forms.Control.D efWndProc(Messa ge& m)
at System.Windows. Forms.Control.W ndProc(Message& m)
at System.Windows. Forms.TextBoxBa se.WndProc(Mess age& m)
at System.Windows. Forms.RichTextB ox.WndProc(Mess age& m)
at System.Windows. Forms.ControlNa tiveWindow.OnMe ssage(Message& m)
at System.Windows. Forms.ControlNa tiveWindow.WndP roc(Message& m)
at System.Windows. Forms.NativeWin dow.Callback(In tPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)

Why ? Is it problem with synchronization : that many threads try to
change Text property at the same time, or what ?
How can i solve this problem ?

Thanx
Michal

Nov 16 '05 #1
1 2131
vertigo,

if you access any UI control from threads you might have similar problems.
Most of UI controls are single-threaded by definition and you can safely
access them only from UI thread.

HTH
Alex
"vertigo" <ax***@wp.pl> wrote in message
news:cn******** **@nemesis.news .tpi.pl...
Hello
I have some Threads, and they write something to
RichTextBox.Tex t property. But sometimes i receive error:

************** Exception Text **************
System.NullRefe renceException: Object reference not set to an instance
of an object.
at System.Windows. Forms.RichTextB ox.EditStreamPr oc(IntPtr dwCookie,
IntPtr buf, Int32 cb, Int32& transferred)
at System.Windows. Forms.UnsafeNat iveMethods.Call WindowProc(IntP tr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows. Forms.NativeWin dow.DefWndProc( Message& m)
at System.Windows. Forms.Control.D efWndProc(Messa ge& m)
at System.Windows. Forms.Control.W ndProc(Message& m)
at System.Windows. Forms.TextBoxBa se.WndProc(Mess age& m)
at System.Windows. Forms.RichTextB ox.WndProc(Mess age& m)
at System.Windows. Forms.ControlNa tiveWindow.OnMe ssage(Message& m)
at System.Windows. Forms.ControlNa tiveWindow.WndP roc(Message& m)
at System.Windows. Forms.NativeWin dow.Callback(In tPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)

Why ? Is it problem with synchronization : that many threads try to
change Text property at the same time, or what ?
How can i solve this problem ?

Thanx
Michal

Nov 16 '05 #2

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

Similar topics

2
3201
by: KenH | last post by:
I am getting an unhandled system exception while writing to a RichTextBox. The process may run for a few hours or days before the error is generated The message is "Cannot access a disposed object named RICHTEXTBOX." A check of the stack trace indicates the error is from the DLL that controls writing to the RTB. The form has not been closed and the line of code referenced is in a catch block that writes any error to this form's RTB (named...
1
2499
by: Nathan Carroll | last post by:
In an mdi environment I constructed a child for with a richtextbox control that is used to load .rtf's. This works fine on the intiatial load of the form but when for is closed and reopened later I get: System.ObjectDisposedException: Cannot access a disposed object named "RichTextBox". Object name: "RichTextBox". at System.Windows.Forms.Control.CreateHandle() at System.Windows.Forms.TextBoxBase.CreateHandle() at...
2
1219
by: Dave | last post by:
I have a button on a form that calls a function. The function does some stuff and then I want it to write the results to a richTextBox. The problem is the code; richTextBox1.Text += "Results"; Gives me the error, 'Form1.righTextBox1' denotes a field where a class was expected. How do I reference the richTextBox from the function?
5
6114
by: mthgk | last post by:
I have a C# MDI app. The child forms do alot of work, so this work is perfomed on a different thread created using ThreadPool.QueueUserWorkItem(). Because the status of the work is important to the user, I post the results in a richTextBox on the child form. I have created an event to do this since it is best to update the controls using the thread that they were created with (or so I've read). Anyway, the first time the user selects a...
1
2691
by: Eric | last post by:
Using the 1.1 framework. We are using a newly created instance of a RichTextBox Class in our server code to manipulate RTF that is stored in the database. To clarify, we are not using or attempting to use this class in the aspx page that calls the code, nor is the 'using System.Windows.Forms' referenced in any of the aspx pages. The first client using this software has been experiencing an error that we cannot reproduce in-house. The...
0
2116
by: y2k692hu | last post by:
Hello I am trying to run this and I keep getting a "SystemNullReferenceException: Object reference not set to instance of an object" error. I have three menu items bold, italic and underline. When i select the text in my RichTextBox, in order to format it bold, italic or underline, I get that error. The debugger points to my Private Sub UpdateMenuItems - the first line of that sub ->where it says "If rtbMain.SelectionFont.Italic = True ".I want...
0
2153
by: James Manila Dot Net | last post by:
I've been having a major problem using the Rtf property of the Richtextbox. I use the RTB to generate RTF code to save it in an access database. I'm successfully able to do this. However, the moment I retrieve the RTF code from the database back to the Rtf property, it ignores any tags that refer to bullet information. I don't understand why. This is the code that is stored in the database generated by the Richtextbox:
1
2367
by: gazelle04 | last post by:
I'm trying to use the "RichTextBox" control so that I can have a text box where you can format the selected text's font, size, and colors but when I insert that Active X control it gives an error "Microsoft Access Does Not support this Active X control". I'm using a MS Access 2003 in the office. How can I use that control.
5
6100
by: Andrus | last post by:
I use Winforms RichTextBox control to edit scripts. Scripts are plain ascii texts. When error occurs, script engine returns character position of error in code as integer. How to position cursor to this character position ? RichTextBox does not have current position property. Andrus.
0
9680
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
10456
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10174
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
10012
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
6788
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
5442
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...
0
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4118
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
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.