Excel generation in a different thread fails.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DS

    Excel generation in a different thread fails.

    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.Unautho rizedAccessExce ption'
    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

    #2
    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@mi crosoft.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.Unautho rizedAccessExce ption'
    > 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]


    Comment

    • DS

      #3
      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@mi crosoft.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.Unautho rizedAccessExce ption'
      > > 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]

      Comment

      • dwernli@evitechnology.com

        #4
        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 programmaticall y set the security context ofthe child thread
        to that of the parent? Please send answer to
        dwernli@evitech nology.com. Thanks loads.

        Thanks,
        Dave Wernli
        dwernli@evitech nology.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@mi crosoft.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.Unautho rizedAccessExce ption'
        > > 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]

        Comment

        Working...