I have a scheduled job that processes XML, adds data and logs each add using Elmah. Our client is testing the with roughly 3500 records in the XML and has found that on one occasion (so far) that two of the records did not process (I'm assuming the last two). The error presented suggests the TCP session ending and the new session token not matching - I presume due to the time taken for processing.
Error: System.ArgumentException: Invalid token for impersonation - it cannot be duplicated
Stack trace points to the line of code in bold:
//log outside of http context //windows identity can be disposed so recreated it //(e.g. this was necessart for episerver scheduled task which runs under web app outside of http context) var token = WindowsIdentity.GetCurrent().Token; var identity = new WindowsIdentity(token); var principal = new WindowsPrincipal(identity); Thread.CurrentPrincipal = principal;
I've not seen this before even with jobs that take some time to process. Anyone have any ideas on how to prevent this error?
Hi,
I have a scheduled job that processes XML, adds data and logs each add using Elmah. Our client is testing the with roughly 3500 records in the XML and has found that on one occasion (so far) that two of the records did not process (I'm assuming the last two). The error presented suggests the TCP session ending and the new session token not matching - I presume due to the time taken for processing.
Error: System.ArgumentException: Invalid token for impersonation - it cannot be duplicated
Stack trace points to the line of code in bold:
//log outside of http context
//windows identity can be disposed so recreated it
//(e.g. this was necessart for episerver scheduled task which runs under web app outside of http context)
var token = WindowsIdentity.GetCurrent().Token;
var identity = new WindowsIdentity(token);
var principal = new WindowsPrincipal(identity);
Thread.CurrentPrincipal = principal;
I've not seen this before even with jobs that take some time to process. Anyone have any ideas on how to prevent this error?
Thanks,
Mark