Error with Response.End()

Hi

im using version 2.1.5.0
i build 2 types of documents (using the same code as in your examples)

the first doc only uses one datatable so uses:-

doc.MailMerge.Execute(dsResults.Tables(0))

the second doc uses 3 datatables so uses:-

doc.MailMerge.ExecuteWithRegions(dsResults)

with the doc having the correct format for starting and ending tables

i am having problems with the 2nd method, the problem occurs at the very end of the process after it has collected all the data and then built the doc ready for display

'Stream the document to the client browser.
doc.Save( \_
String.Format("{0}.doc", param), \_
SaveFormat.FormatDocument, \_
SaveType.OpenInBrowser, Response)

Response.End()

when it gets to Response.End() it errors with “Thread was being aborted”

any idea’s as to why?

Cheers,
Craig

Response.End does a Thread Abort. By design. From the documentation on MSDN:

“Calls to End, Redirect, and Transfer] raise a ThreadAbortException when the current response ends prematurely.”

so what would be causing it to end prematurely? and why does it only happen when i use ExecuteWithRegions

the dataset is setup as follows

dsResultSet.Tables(0).TableName = "Therapy"
dsResultSet.Tables(1).TableName = "Advice"
dsResultSet.Tables(2).TableName = "Client"

and populates fine

the doc template is as follows

<<TableStart:Client>>

–then all the cleint fields 

<<TableEnd:Client>>
<<TableStart:Advice>>

–then all the advice fields 

<<TableEnd:Advice>>
<<TableStart:Therapy>>

–then all the therapy fields 

<<TableEnd:Therapy>>

In your code, you have this line:

Response.End()

That is where the exception is taking place, if you are catching a Thread Abort exception.