SqlConnection instantiation exception on .NET 4.6 and later after August-September 2018 .NET Framework updates

Symptoms

After you install the August Preview of Quality Rollup or September 11, 2018, .NET Framework update, instantiation of SqlConnection can throw an exception.

Use of a SqlConnection constructor can lead to a stack trace that resembles the following:

 System.Runtime.Serialization.SerializationException
   at System.AppDomain.get_Evidence()
   at System.AppDomain.get_Evidence()
   at System.Configuration.ClientConfigPaths.GetEvidenceInfo(AppDomain appDomain, String exePath, String& typeName)
   at System.Configuration.ClientConfigPaths.GetTypeAndHashSuffix(AppDomain appDomain, String exePath)
   at System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig)
   at System.Configuration.ClientConfigPaths.GetPaths(String exePath, Boolean includeUserConfig)
   at System.Configuration.ClientConfigurationHost.RequireCompleteInit(IInternalConfigRecord record)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
   at System.Configuration.ConfigurationManager.GetSection(String sectionName)
   at System.Data.SqlClient.SqlConnection..cctor()

Workaround

Workaround 1

Add the following lines in the configSection of the App.Config file of the application:

<section name="SqlColumnEncryptionEnclaveProviders"
type="System.Data.SqlClient.SqlColumnEncryptionEnclaveProviderConfigurationSection,
System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

Note  If your application doesn't include an app.config file, we recommend that you create and deploy an app.config file that contains this information in the configSection.

If Workaround 1 doesn't work, try Workaround 2.

Workaround 2

Identify a place in the app domain that runs before any objects have been added to the logical call context. Add code to force ConfigurationManager to try to load a section that doesn't exist in any configuration files. For example:

System.Configuration.ConfigurationManager.GetSection("SectionNameThatDoesNotExistInAnyConfigurationFile");

For more information about this issue see the GitHub article Mitigation: Deserialization of objects across app domains.

Status

Microsoft is researching this issue and will provide an update in an upcoming release.

Ali potrebujete dodatno pomoč?

Razširite svoja znanja
Oglejte si izobraževanje
Prvi dobite nove funkcije
Pridruži se Microsoftu programa Insider

Vam je bila informacija v pomoč?

Zahvaljujemo se vam za povratne informacije.

Zahvaljujemo se vam za povratne informacije. Videti je, da bi vam prišla prav pomoč enega od naših Officeovih agentov za podporo.

×