473,785 Members | 2,841 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 1590
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
2908
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
1910
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
7451
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
9645
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
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10330
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...
0
10153
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...
0
9952
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
5381
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
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
3654
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.