Upon successfully installing source package of DNN 5.5.0 (336) Beta, noted in Event Viewer the following error which occurred during the install:
StackTrace:
Message: System.Data.SqlClient.SqlException: Violation of PRIMARY KEY constraint 'PK_DNN_HostSettings'. Cannot insert duplicate key in object 'dbo.DNN_HostSettings'. The statement has been terminated. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(SqlConnection connection, CommandType commandType, String commandText, SqlParameter[] commandParameters) at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(String connectionString, CommandType commandType, String commandText, SqlParameter[] commandParameters) at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(String connectionString, String spName, Object[] parameterValues) at DotNetNuke.Data.SqlDataProvider.AddHostSetting(String SettingName, String SettingValue, Boolean SettingIsSecure, Int32 CreatedByUserID) at DotNetNuke.Entities.Controllers.HostController.Update(ConfigurationSetting config, Boolean clearCache) in C:\DNN Websites\DNN550Beta\Library\Entities\Controllers\HostController.vb:line 47
I then accessed Host Settings tab and noted that each attempt to update host settings resulted in multiple iinstances of this same error being logged. Traced the error down to the following fragment found in the Update method in the new HostController class:
If GetSettings.ContainsKey(config.Key) Then
DataProvider.Instance().UpdateHostSetting(config.Key, config.Value, config.IsSecure, UserController.GetCurrentUserInfo.UserID)
objEventLog.AddLog(config.Key, config.Value, PortalController.GetCurrentPortalSettings, UserController.GetCurrentUserInfo.UserID,
Log.EventLog.EventLogController.EventLogType.HOST_SETTING_UPDATED)
Else
DataProvider.Instance().AddHostSetting(config.Key, config.Value, config.IsSecure, UserController.GetCurrentUserInfo.UserID)
objEventLog.AddLog(config.Key, config.Value, PortalController.GetCurrentPortalSettings, UserController.GetCurrentUserInfo.UserID,
Log.EventLog.EventLogController.EventLogType.HOST_SETTING_CREATED)
End If
Since the host settings dictionary returned by GetSettings does not contain entries for any SettingName containing "password", the above condition will always be false for keys "SMTPPassword", "ProcessorPassword" and "ProxyPassword" resulting in AddHostSetting always being called for these three keys and the resulting PK violation being generated due to the duplication of a key alread in the Host Settings table. Due to the error, any changes to these keys will not be saved to the database.
The cached host settings dictionary is initially generated in the following callback method of HostController:
Private Function GetSettingsDictionaryCallBack(ByVal cacheItemArgs As CacheItemArgs) As Object
Dim dicSettings As New Dictionary(Of String, ConfigurationSetting)
Dim dr As IDataReader
Try
dr = DataProvider.Instance().GetHostSettings
While dr.Read()
Dim key As String = dr.GetString(0)
If Not key.ToLower().Contains("password") Then
Dim config As New ConfigurationSetting()
config.Key = key
config.IsSecure = Convert.ToBoolean(dr(2))
If dr.IsDBNull(1) Then
config.Value = String.Empty
Else
config.Value = dr.GetString(1)
End If
dicSettings.Add(key, config)
End If
End While
Catch ex As Exception
LogException(ex)
Finally
CBO.CloseDataReader(dr, True)
End Try
Return dicSettings
End Function
As you can see, any setting key containing "password" will be excluded from the settings dictionary.
I did not see this issue in Gemini and will log it.
EDIT: Logged in Gemini as http://support.dotnetnuke.com/issue/V...