Connecting Tech Pros Worldwide Forums | Help | Site Map

Excel generation in a different thread fails.

DS
Guest
 
Posts: n/a
#1: Nov 20 '05
I try to generate a excel workbook using Excel object in ASP.NET program.
When I implement the Excel workbook generation with out a thread it works
fine. When I wrap all the excel generation process inside a method, and spin
this method in a different thread I get the following error:

"An unhandled exception of type 'System.UnauthorizedAccessException'
occurred in Unknown Module.
Additional information: Access is denied."

I am stuck with this. Waiting for comments & suggestions on how to generate
a Excel work book in a different thread.

Thanks in advance.
DS

Bruce Barker
Guest
 
Posts: n/a
#2: Nov 20 '05

re: Excel generation in a different thread fails.


when you start a thread, it runs under the default process security context,
not that of the creating thread. you will need to have the new thread
impersonate the security of the creating thread. also new thread will not be
associated the correct httpcontext, so if you need it, pass it.


-- bruce (sqlwork.com)


"DS" <DS@discussions.microsoft.com> wrote in message
news:4ECEB799-3AAF-4351-89C2-250C17AD7524@microsoft.com...[color=blue]
>I try to generate a excel workbook using Excel object in ASP.NET program.
> When I implement the Excel workbook generation with out a thread it works
> fine. When I wrap all the excel generation process inside a method, and
> spin
> this method in a different thread I get the following error:
>
> "An unhandled exception of type 'System.UnauthorizedAccessException'
> occurred in Unknown Module.
> Additional information: Access is denied."
>
> I am stuck with this. Waiting for comments & suggestions on how to
> generate
> a Excel work book in a different thread.
>
> Thanks in advance.
> DS[/color]


DS
Guest
 
Posts: n/a
#3: Nov 20 '05

re: Excel generation in a different thread fails.


Bruce

So, what changes should I make to my program in order to impersonate the new
Thread. Please explain.

Thanks,
DS




"Bruce Barker" wrote:
[color=blue]
> when you start a thread, it runs under the default process security context,
> not that of the creating thread. you will need to have the new thread
> impersonate the security of the creating thread. also new thread will not be
> associated the correct httpcontext, so if you need it, pass it.
>
>
> -- bruce (sqlwork.com)
>
>
> "DS" <DS@discussions.microsoft.com> wrote in message
> news:4ECEB799-3AAF-4351-89C2-250C17AD7524@microsoft.com...[color=green]
> >I try to generate a excel workbook using Excel object in ASP.NET program.
> > When I implement the Excel workbook generation with out a thread it works
> > fine. When I wrap all the excel generation process inside a method, and
> > spin
> > this method in a different thread I get the following error:
> >
> > "An unhandled exception of type 'System.UnauthorizedAccessException'
> > occurred in Unknown Module.
> > Additional information: Access is denied."
> >
> > I am stuck with this. Waiting for comments & suggestions on how to
> > generate
> > a Excel work book in a different thread.
> >
> > Thanks in advance.
> > DS[/color]
>
>
>[/color]
dwernli@evitechnology.com
Guest
 
Posts: n/a
#4: Nov 21 '05

re: Excel generation in a different thread fails.


Bruce,

Saw your reply to DS but didn't see how to actually set the security
context of the created thread. I am having the exact same problem as
DS -- can't access objects in a child thread that I can in the parent
thread.

How do I programmatically set the security context ofthe child thread
to that of the parent? Please send answer to
dwernli@evitechnology.com. Thanks loads.

Thanks,
Dave Wernli
dwernli@evitechnology.com
(540)845-1225


Bruce Barker wrote:[color=blue]
> when you start a thread, it runs under the default process security context,
> not that of the creating thread. you will need to have the new thread
> impersonate the security of the creating thread. also new thread will not be
> associated the correct httpcontext, so if you need it, pass it.
>
>
> -- bruce (sqlwork.com)
>
>
> "DS" <DS@discussions.microsoft.com> wrote in message
> news:4ECEB799-3AAF-4351-89C2-250C17AD7524@microsoft.com...[color=green]
> >I try to generate a excel workbook using Excel object in ASP.NET program.
> > When I implement the Excel workbook generation with out a thread it works
> > fine. When I wrap all the excel generation process inside a method, and
> > spin
> > this method in a different thread I get the following error:
> >
> > "An unhandled exception of type 'System.UnauthorizedAccessException'
> > occurred in Unknown Module.
> > Additional information: Access is denied."
> >
> > I am stuck with this. Waiting for comments & suggestions on how to
> > generate
> > a Excel work book in a different thread.
> >
> > Thanks in advance.
> > DS[/color][/color]

Closed Thread