473,770 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ThreadAbortExce ption Question

Hello,

I have a piece of code where I am writing the contents of a datagrid to
an excel report

Dim tw As New StringWriter()
Dim hw As New System.Web.UI.H tmlTextWriter(t w)
Dim frm As HtmlForm = New HtmlForm()
Response.Conten tType = "applicatio n/vnd.ms-excel"
Response.AddHea der("content-disposition",
"attachment;fil ename=Test.xls" )
Response.Charse t = ""
EnableViewState = False
Controls.Add(fr m)
frm.Controls.Ad d(grid2)
frm.RenderContr ol(hw)

Response.Write( tw.ToString())
Response.End()

it works fine.

In debug mode, after I closed down the excel report and exited the
program, I saw the following message in the debug window

"A first chance exception of type
'System.Threadi ng.ThreadAbortE xception' occurred in mscorlib.dll
An exception of type 'System.Threadi ng.ThreadAbortE xception' occurred
in mscorlib.dll but was not handled in user code
The program '[1368] WebDev.WebServe r.EXE: Managed' has exited with code
0 (0x0)."

I looked at msdn

http://msdn.microsoft.com/library/?u...classtopic.asp
and put a try-catch block around the code to ctach ThreadAbortExce ption
but this time it came back with a "page can not have 2 forms error".

The program works fine. Is this a serious issue? Do I need to catch
this exception? It seems like catching it actually mad ethings worse.

Thanks,

Burak

Apr 6 '06 #1
1 1589
Response.End() intentionally throws a ThreadAbortExce ption - it's actually
how it works.

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Burak Gunay" <bu*****@aol.co m> wrote in message
news:11******** **************@ z34g2000cwc.goo glegroups.com.. .
Hello,

I have a piece of code where I am writing the contents of a datagrid to
an excel report

Dim tw As New StringWriter()
Dim hw As New System.Web.UI.H tmlTextWriter(t w)
Dim frm As HtmlForm = New HtmlForm()
Response.Conten tType = "applicatio n/vnd.ms-excel"
Response.AddHea der("content-disposition",
"attachment;fil ename=Test.xls" )
Response.Charse t = ""
EnableViewState = False
Controls.Add(fr m)
frm.Controls.Ad d(grid2)
frm.RenderContr ol(hw)

Response.Write( tw.ToString())
Response.End()

it works fine.

In debug mode, after I closed down the excel report and exited the
program, I saw the following message in the debug window

"A first chance exception of type
'System.Threadi ng.ThreadAbortE xception' occurred in mscorlib.dll
An exception of type 'System.Threadi ng.ThreadAbortE xception' occurred
in mscorlib.dll but was not handled in user code
The program '[1368] WebDev.WebServe r.EXE: Managed' has exited with code
0 (0x0)."

I looked at msdn

http://msdn.microsoft.com/library/?u...classtopic.asp
and put a try-catch block around the code to ctach ThreadAbortExce ption
but this time it came back with a "page can not have 2 forms error".

The program works fine. Is this a serious issue? Do I need to catch
this exception? It seems like catching it actually mad ethings worse.

Thanks,

Burak

Apr 6 '06 #2

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

Similar topics

4
2907
by: Vivek | last post by:
Hi, I have a question regarding ThreadAbortException. Why is the thread abort exception rethrown at the end of a catch clause? Why is ThreadAbortException's behavior designed to be this way? Thanks in advance -Vivek
6
2146
by: David Waz... | last post by:
Moved an app from W/2000 Asp V1.0 to W/2003, VS/2003, ASPV 1.1 Page runs a long job, uploading 2 large fixed length files (300,000 rows) into SQL database. A process is run against the data, and altered flat-files produced. The job aborts at EXACTLY 105 seconds (1 min, 45 seconds) regardless of WHERE in the process we are - could be DB read, DB write, string manipulation - whatever.
0
1337
by: Chee | last post by:
Hi all Please forgive me if this has been asked before. I am getting a ThreadAbortException in "Unknown Module" when i try to load a page from VS.NET. One problem is it does not happen all the time. But with more projects being added to the reference list, I will get it more often. When it happens, I loss information in the Session as it get restarted, and some event doesn't happened (i.e. IndexChanged event in dropdownlist, onclick event...
3
1909
by: Steve - DND | last post by:
I just implemented a page that performs a Response.Redirect(url, true). As such, I wrapped it in a try catch, and explicitly caught a ThreadAbortException. However, the thread abort exception was still thrown at every catch block above the try/catches level, as well as at the *same* level as the try/catch. This does not seem like proper behavior at all. Once I've caught the exception, why is it still propagating up the stack? I could maybe...
4
1737
by: splap20 | last post by:
Every day a large chunk of XML is posted up to my app via http. The app interprets this XML and writes results to a SQLServer. Occasionally a ThreadAbortException is thrown during this process. Despite being caught, this exception propagates all the way up the call stack. I know this is by design and that I can use Thread.ResetAbort to stop this exception from bubbling up the stack. But I want to know why the exception is thrown in the...
1
2402
by: Eric | last post by:
I have the following situation: I was getting intermittent errors using Reponse.Redirct("url", true) and was trying to catch the ThreadAbortException, but it was not staying caught and was showing up again where my code wasnt expecting it. I'm not sure what was causing it. The catch block in RedirectPage is supposed to quash the ThreadAbortException but it not only shows up there, but also in the outer catch block will catch it as well....
6
7450
by: foolmelon | last post by:
If a childThread is in the middle of a catch block and handling an exception caught, the main thread calls childThread.Abort(). At that time a ThreadAbortException is thrown in the childThread. The question is: after the ThreadAbortException is thrown, does the childThread continue run the remaining code in the catch block?
3
3351
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= | last post by:
Hi, I am running a web service which sometimes throws exceptions. I have a lot of error trapping within the web service, but I have missed the current problem. I am working on the current issue, but there even when I get this fixed, there may be others I have not thought of. My immediate problem is that the web service seems to throw a threadabortexception to the client when it has an uncaught exception (I may be wrong. I am a bit confused...
0
1642
by: Zeba | last post by:
Hi ! I am using a httphandler to perform some url rewriting in my application. My web.config contains the following entry to direct all urls containing /App/*.ashx to my class AppHandler.cs in namespace mySite.Web <httpHandlers> <add verb="*" path="App/*.ashx" type="mySite.Web.AppHandler, App_Code"/>
0
10059
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
10005
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
9871
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
8887
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5313
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
5452
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3972
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
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2817
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.