From a696100260a66c55c396357e7e0886806bd75183 Mon Sep 17 00:00:00 2001 From: Davoud Eshtehari Date: Thu, 6 Feb 2020 17:09:09 -0800 Subject: [PATCH 1/2] Fix issue (#401) --- .../Data/Interop/SNINativeMethodWrapper.cs | 5 +--- ....Data.SqlClient.ManualTesting.Tests.csproj | 1 + .../SqlDependencyTest/SqlDependencyTest.cs | 26 +++++++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDependencyTest/SqlDependencyTest.cs diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs index f942f1c9c0..c6a2977ffc 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Interop/SNINativeMethodWrapper.cs @@ -80,10 +80,7 @@ internal static int SniMaxComposedSpnLength static AppDomain GetDefaultAppDomainInternal() { - var host = new mscoree.CorRuntimeHost(); - host.GetDefaultDomain(out object temp); - AppDomain defaultAppDomain = temp as AppDomain; - return defaultAppDomain; + return AppDomain.CurrentDomain; } internal static _AppDomain GetDefaultAppDomain() diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj b/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj index eb9afe1731..a1cb241256 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj @@ -115,6 +115,7 @@ + diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDependencyTest/SqlDependencyTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDependencyTest/SqlDependencyTest.cs new file mode 100644 index 0000000000..bfa36f84fc --- /dev/null +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDependencyTest/SqlDependencyTest.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using Xunit; + +namespace Microsoft.Data.SqlClient.ManualTesting.Tests +{ + public class SqlDependencyTest + { + [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] + public void SqlDependencyStartStopTest() + { + try + { + SqlDependency.Start(DataTestUtility.TCPConnectionString); + SqlDependency.Stop(DataTestUtility.TCPConnectionString); + } + catch (Exception e) + { + Assert.True(false, e.Message); + } + } + } +} From b956c7993f2efeb5cdf3f5793d548c720c85b751 Mon Sep 17 00:00:00 2001 From: David Eshtehari Date: Mon, 6 Apr 2020 18:43:26 -0700 Subject: [PATCH 2/2] Tidied up. --- .../ManualTests/SQL/SqlDependencyTest/SqlDependencyTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDependencyTest/SqlDependencyTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDependencyTest/SqlDependencyTest.cs index bfa36f84fc..7bc2494b42 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDependencyTest/SqlDependencyTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/SqlDependencyTest/SqlDependencyTest.cs @@ -9,7 +9,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests { public class SqlDependencyTest { - [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] + [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))] public void SqlDependencyStartStopTest() { try