Exception StackTrace shows a method not in code!
See original GitHub issueHi,
I see an exception and I try to relate the exception stack trace with the code, but as per the code, the top method in stack is not there in code! What am I not able to see here?
[Error] System.AggregateException: One or more errors occurred. (One or more errors occurred. (Access is denied) (Access is denied)) ---> System.AggregateException: One or more errors occurred. (Access is denied) (Access is denied) ---> System.Security.SecurityException: Access is denied
at System.Security.Principal.WindowsIdentity.GetCurrentInternal(TokenAccessLevels desiredAccess, Boolean threadOnly)
at Microsoft.Data.ProviderBase.DbConnectionPoolIdentity.GetCurrentNative()
at Microsoft.Data.ProviderBase.DbConnectionPoolGroup.GetConnectionPool(DbConnectionFactory connectionFactory)
at Microsoft.Data.ProviderBase.DbConnectionFactory.GetConnectionPool(DbConnection owningObject, DbConnectionPoolGroup connectionPoolGroup)
at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at Microsoft.Data.SqlClient.SqlConnection.OpenAsync(CancellationToken cancellationToken)
As per the source code https://github.com/dotnet/SqlClient/blob/master/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionPoolIdentity.Windows.cs, there is no call made to “WindowsIdentity.GetCurrentInternal”. Then why is the stack trace showing it?
I get this exception when I try to impersonate another person on my machine (which succeeds) but SQL Client is unable to open a connection.
Can anyone help?
TIA!
Nayan
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
c# - Exception's stacktrace doesn't show where the ...
Typically when I throw an exception, catch it, and print out the stacktrace, I get to see the call where the exception was...
Read more >Java Stack Trace: How to Read and Understand to Debug ...
Usually, a stack trace is shown when an Exception is not handled correctly in code. (An exception is what a runtime environment uses...
Read more >c# - How can we avoid showing the literal path in ...
When our in-house developed application (C#, ASP.NET) is throwing an exception, it displays a stack trace that contains path information like C ...
Read more >Exception.StackTrace Property (System)
The StackTrace property may not report as many method calls as expected because of code transformations, such as inlining, that occur during optimization....
Read more >#21942 Exception line number at end of method
Briefly, when an exception is thrown and I get a stack trace, the exception line number is set to the last line of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

We call
Windows.GetCurrent()https://github.com/dotnet/SqlClient/blob/a9dfe480eff5dd344518eab5198654eff969fb6e/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionPoolIdentity.Windows.cs#L23
which calls
GetCurrentInternal()by making a Sibling/Tail call, which is not captured by Stack Trace.Reference source: windowsidentity.cs#L263-L267.
Regarding the exception, you might wanna try giving Security permission to the impersonated user account.
Closing this issue as answered, if you need support on more topics from SqlClient, please open a new issue with repro attached.