473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Understanding a 'thread was being aborted/mscorlib' exception

I have a function that calls a class that writes a dataset that I've passed
to it out as an excel spreadheet and returns it to the browser:

my function
try
makeExcelFile(mydataset)
catch
response write the exceptions
end try
end function

This works. However, at the very bottom of my excel spreadsheet that gets
generated, it prints out the CATCH response write from my function:

Thread was being aborted.
mscorlib

From a bit of googling, I can't quite tell if that's an error, or just a
normal response and that I probably should just check for that specific
response and not bother writing it out.

I'm also a bit confused as to why it's writing the error the spreadsheet.
Should the spreadsheet be written, that function returns the exception, then
my function catch it and, in turn, write the exception back to the screen?

-Darrel
Mar 9 '06 #1
5 6125
Oh, and here's the function that is apparently returning that exception:

Public Shared Sub Convert(ByVal ds As DataSet, ByVal response As
HttpResponse)
'first let's clean up the response.object
response.Clear()
response.Charset = ""
'set the response mime type for excel
response.ContentType = "application/vnd.ms-excel"
'create a string writer
Dim stringWrite As New System.IO.StringWriter
'create an htmltextwriter which uses the stringwriter
Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
'instantiate a datagrid
Dim dg As New DataGrid
'set the datagrid datasource to the dataset passed in
dg.DataSource = ds.Tables(0)
'bind the datagrid
dg.DataBind()
'tell the datagrid to render itself to our htmltextwriter
dg.RenderControl(htmlWrite)
'all that's left is to output the html
response.Write(stringWrite.ToString)
response.End()
End Sub

-darrel
Mar 9 '06 #2
"darrel" wrote:
This works. However, at the very bottom of my excel spreadsheet that gets
generated, it prints out the CATCH response write from my function:

Thread was being aborted.
mscorlib


From the blog of a friend:

"This problem occurs when calling a Response.Redirect() or a
Server.Transfer() within a Try...Catch block. This is because the
Response.Redirect() method will call the Response.End() method and the
Response.End() method will call the Abort() method of the running thread."

Steven

- - -
Mar 9 '06 #3
"darrel" wrote:
Oh, and here's the function that is apparently returning that exception:
Based on my previous post, this line is to blame:
response.End()


Steven

- - -

Mar 9 '06 #4
> From the blog of a friend:

"This problem occurs when calling a Response.Redirect() or a
Server.Transfer() within a Try...Catch block. This is because the
Response.Redirect() method will call the Response.End() method and the
Response.End() method will call the Abort() method of the running thread."


Thanks. I saw that too. However, neither of the functions are calling a
server transfer or response.redirect. It IS using a bunch of other
response.* calls, though (see my other reply) so perhaps one of those is the
culprit.

AFAICT, there's no actual error, as all the data is rendered.

-Darrel
Mar 9 '06 #5
Based on my previous post, this line is to blame:
response.End()


Ah! Great. Mystery solved!

Thanks!

-Darrel
Mar 9 '06 #6

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

Similar topics

1
by: Alan Baljeu | last post by:
My code calls int.Parse(text), which throws a System.Format exception. This is fine because text is all letters, and I explicitly catch the exception. However, my program never receives the...
1
by: Elliot M. Rodriguez | last post by:
A few of our customers cannot access one of the pages on our vb.net asp.net site. The problems are limited to only a few people, but these people have the problem regularly. The page in question...
2
by: T. | last post by:
I had the following code inside my app try { // Open an ADO.NET db connection // Do some db processing here Response.Redirect("main.htm"); } catch(Exception e) {
2
by: Mark Denardo | last post by:
I'm trying to abort a suspended thread, but I get a ThreadStateException: An unhandled exception of type 'System.Threading.ThreadStateException' occurred in mscorlib.dll Additional...
5
by: Jimi | last post by:
Hi all, I have a user control which raises an event to the parent page when a person clicks on a link in a datagrid. In the event handler inside the parent page I construct a url to redirect to...
4
by: R.A.M. | last post by:
Hello, Could you help me plase? I have an ASP.NET page with "Search" button; when button is clicked Search_Click is called; here's the code: protected void Search_Click(object sender, EventArgs...
1
by: R.A.M. | last post by:
Hello, Could you help me plase? I am describing my problem second time because I haven't got a solution. I have an ASP.NET page with "Search" button; when button is clicked Search_Click is...
9
by: esakal | last post by:
Hello, I'm programming an application based on CAB infrastructure in the client side (c# .net 2005) Since my application must be sequencally, i wrote all the code in the UI thread. my...
0
by: roni schuetz | last post by:
since a few day's i'm running around the problem that I stocked with a change i need to do. hopefully somebody here can give me a tipp which will be usefull to solve my problem. I'm using a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
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,...

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.