472,988 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,988 software developers and data experts.

Suspect error using RichTextBox Class in server code

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 error occurs intermittently anywhere
after 2-4 days of use, so it is not something reproducible on demand.
The fix is to restart IIS and on a couple of occasions a restart of
the server was necessary. The error is being trapped in code and
returned as string to the user which displays on the aspx page so it
is not an unhandled exception with a dump of the stack trace. The
error message is 'Error creating window handle". Once one user
receives this error all users receive the same error when trying to
perform the same operation. I am not 100% sure that the RichTextBox
code is what is causing the error but based on the message involved it
is my best guess. Here is a code snipit that shows how we are using
the RichTextBox.

string strFreeRTF = drRow["FRTF"].ToString().Trim();
string strTempRTF = drRow["TMPLTRTF"].ToString().Trim();
RichTextBox rtfFree = new RichTextBox();
rtfFree.Rtf = strFreeRTF; //prevents null reference
RichTextBox rtfTemp = new RichTextBox();
rtfTemp.Rtf = strTempRTF;
if(rtfTemp.Text.Length > 0)
{
rtfFree.AppendText("\r\n");
rtfTemp.SelectAll();
rtfTemp.Copy();
rtfFree.Paste();
}
if(strCodedCharting.Length > 0)
{
rtfFree.AppendText("\r\n");
rtfFree.AppendText(strCodedCharting);
}

if(drChart["SUMMARY"].ToString() != "")
{
if(rtfFree.Text.Length > 0)
{
rtfFree.AppendText("\r\n");
}
rtfFree.AppendText(drRow["SMRYTXT"].ToString());
}
if(rtfFree.Text != "")
strRet = rtfFree.Rtf;
return strRet;

The code performs what it is designed to do but obviously we need to
track down why the error occurs.

Does anyone have information that might assist with troubleshooting
this problem. Thanks
Nov 18 '05 #1
1 2636
using winform controls are not supported by aspx pages. they require a
window handle to perform correctly, and system services like iis and
asp.net, do not have permission to create a window handle as they need
access to the desktop.

you might get away with it if the console is alway logged on the server, and
you gave permission. you still run the risk, that if the control pop's up a
dialog box (say for en error), your asp.net thread will be blocked until
some goes to the console and responds to the dialogbox.

this is very poor design, and you should look at replacing the rtf control
as soon as possible.

-- bruce (sqlwork.com)

"Eric" <ms*********@nospammediserve.com> wrote in message
news:3f*****************@news.devexpress.com...
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 error occurs intermittently anywhere
after 2-4 days of use, so it is not something reproducible on demand.
The fix is to restart IIS and on a couple of occasions a restart of
the server was necessary. The error is being trapped in code and
returned as string to the user which displays on the aspx page so it
is not an unhandled exception with a dump of the stack trace. The
error message is 'Error creating window handle". Once one user
receives this error all users receive the same error when trying to
perform the same operation. I am not 100% sure that the RichTextBox
code is what is causing the error but based on the message involved it
is my best guess. Here is a code snipit that shows how we are using
the RichTextBox.

string strFreeRTF = drRow["FRTF"].ToString().Trim();
string strTempRTF = drRow["TMPLTRTF"].ToString().Trim();
RichTextBox rtfFree = new RichTextBox();
rtfFree.Rtf = strFreeRTF; //prevents null reference
RichTextBox rtfTemp = new RichTextBox();
rtfTemp.Rtf = strTempRTF;
if(rtfTemp.Text.Length > 0)
{
rtfFree.AppendText("\r\n");
rtfTemp.SelectAll();
rtfTemp.Copy();
rtfFree.Paste();
}
if(strCodedCharting.Length > 0)
{
rtfFree.AppendText("\r\n");
rtfFree.AppendText(strCodedCharting);
}

if(drChart["SUMMARY"].ToString() != "")
{
if(rtfFree.Text.Length > 0)
{
rtfFree.AppendText("\r\n");
}
rtfFree.AppendText(drRow["SMRYTXT"].ToString());
}
if(rtfFree.Text != "")
strRet = rtfFree.Rtf;
return strRet;

The code performs what it is designed to do but obviously we need to
track down why the error occurs.

Does anyone have information that might assist with troubleshooting
this problem. Thanks

Nov 18 '05 #2

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

Similar topics

4
by: John Broderick | last post by:
I've got a problem with the RichTextBox control in .Net where the garbage collector doesn't reclaim its memory after I've finished with it. My program adds a series of rtb's to the control array...
2
by: Saiyou Anh | last post by:
I have two questions: (1) How can we diagnose the reason of database suspect? The error log doesn't tell me much. (2) After restart the server, the suspect is gone, but how can I ensure everthing...
1
by: Terminal882003 | last post by:
Hi, I have a problem in my application(C#) if I using RichTextBox to continuously display a series of text messages (using method AppendText()). When application is running, it will stop at some...
1
by: Henry | last post by:
I inherited a richtextbox class and tried to add the double click even handler. Unfortunatly, when I check the properties of rtbText, it doesn't contain a double click event handler. Any ideas on...
4
by: Peter Row | last post by:
Hi, I have created a UserControl which is subsequently hosted on a standard form. My control has a TabControl on it but it has no TabPages configured. At runtime I create X pages and put a...
10
by: D Steward | last post by:
I can't seem to add a newline (/n) to get a richtextbox control to display text on successive lines. The text that I type is overwritten. How do I remedy this My example richTextBox->Multiline...
3
by: michael sorens | last post by:
The documentation for the RichTextBox is sketchy at best. I want to do a very simple task but I cannot find information on this. I am using a RichTextBox as an output window. Some text I want to...
2
by: =?Utf-8?B?TUs=?= | last post by:
Hello , I am developing a white board type stand-alone VB .NET application in which the .EXE application will be installed in two or more different client machines . These client machines...
8
by: =?Utf-8?B?Q2hyaXMgSGFsY3Jvdw==?= | last post by:
Hi there I've successfully added some .NET validation controls to a page (using <asp:RequiredFieldValidator ...), however when I try to set the 'display' property to 'dynamic', my page then...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.