GC problem

  • Thread starter Thread starter Madhu Gopinathan
  • Start date Start date
M

Madhu Gopinathan

Hi,
I am setting System.Threading.Thread.CurrentPrincipal to a Windows
pricipal before I go ahead call methods to process, sometimes cross
assembly.

The problem I am facing is that intermittently the WindowsPrincipal
object within seems to be garbage collected because I get "Handle is
invalid" sometimes.I tried setting GC.KeepAlive
(System.Threading.Thread.CurrentPrincipal) post setting the value in
CurrentPrincipal variable. It did not help the cause.

Is there something amiss in what I am doing here?

Thanks in advance,
Madhu
 
What do you mean with "sometimes cross assembly"? you aren't talking about
cross-domain ain't you?
What's the calling function that throws the "Handle is invalid" error? How
does the call stack looks like?
Don't forget that principals don't flow across threads!
Mind to post a simple sample that illustrates the issue?


Willy.
 
I think sample code would be helpful to illustrate the actual issue.

Just a guess (from the assumption of your scenario):
Declare your 'WindowsPrincipal' object to be public static (Shared in
Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top