dotnet / dotnet/SqlClient

Net9 Tests do not run in Visual Studio

Open
#3,193 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
989
Forks
340
Avg merge
4d 19h
Merged PRs (30d)
72

Description

When developing SqlClient using Visual Studio I want to be able to run the manual tests to make sure that I haven't broken anything. With the tests configured correctly so that they can be run correctly from the commandline it is impossible to run them from within Visual Studio.

Picking a simple test example, this is what you get:

![Image](https://github.com/user-attachments/assets/8817ee52-cc3a-4e3a-9fbd-e9fe80286563)

```
 Microsoft.Data.SqlClient.ManualTesting.Tests.AdapterTest.AutoGenBulkUpdateTest
 Source: AdapterTest.cs line 1204
 Duration: 72 ms

Message: 
System.TypeInitializationException : The type initializer for 'Microsoft.Data.SqlClient.TdsParser' threw an exception.
---- System.TypeInitializationException : The type initializer for 'Microsoft.Data.SqlClient.SNILoadHandle' threw an exception.
-------- System.DllNotFoundException : Unable to load DLL 'Microsoft.Data.SqlClient.SNI.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)

Stack Trace: 
TdsParser.ctor(Boolean MARS, Boolean fAsynchronous) line 34
SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) line 1567
SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) line 1444
SqlInternalConnectionTds.ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken, DbConnectionPool pool, Func`3 accessTokenCallback) line 525
SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) line 138
DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) line 153
DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) line 802
DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) line 1977
DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) line 1361
DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) line 1261
DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) line 306
DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) line 963
DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) line 43
SqlConnection.TryOpen(TaskCompletionSource`1 retry, SqlConnectionOverrides overrides) line 1970
SqlConnection.Open(SqlConnectionOverrides overrides) line 1413
SqlConnection.Open() line 1390
AdapterTest.AutoGenBulkUpdateTest() line 1211
RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
----- Inner Stack Trace -----
TdsParserStateObjectFactory.get_EncryptionOptions() line 22
TdsParser.cctor() line 79
----- Inner Stack Trace -----
SniNativeMethods.SNIInitialize(IntPtr pmo)
SniNativeMethods.SniInitialize(IntPtr pmo) line 58
SniNativeWrapper.SNIInitialize(IntPtr pmo) line 164
SniNativeWrapper.SNIInitialize() line 278
SNILoadHandle.ctor() line 38
SNILoadHandle.ctor() line 22
SNILoadHandle.cctor() line 20
```

Without the ability to trigger the CI as a contributor the local test experience becomes much more important. Currently it is not useful and does not allow test information to be gathered in a sensible way.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.