コードに非常に奇妙な問題があり、失敗することはないと思います。これは、AspDotNetStoreFront に基づいて、ある程度のトラフィックがある Web サイトですが、それほど大きくはありません。リーダーからデータベース フィールドを読み取ろうとすると、サイトが断続的にクラッシュします。これは、Web サイトのさまざまな場所で発生します。このようなコードの例は、以下のobject pValue = rs["PropertyValueString"];の行にあります。
private Dictionary<string, object> GetPropertValuePairs(string userName)
{
string query = string.Format("select PropertyName, PropertyValueString from dbo.profile with(nolock) where CustomerGUID = {0} and StoreID = {1}", DB.SQuote(userName),AppLogic.StoreID());
Dictionary<string, object> propertyValues = new Dictionary<string, object>();
using (SqlConnection conn = new SqlConnection(DB.GetDBConn()))
{
conn.Open();
using (IDataReader rs = DB.GetRS(query, conn))
{
while (rs.Read())
{
string pName = DB.RSField(rs, "PropertyName");
object pValue = rs["PropertyValueString"];
if (propertyValues.ContainsKey(pName) == false)
{
propertyValues.Add(pName, pValue);
}
}
rs.Close();
rs.Dispose();
}
conn.Close();
conn.Dispose();
}
return propertyValues;
}
これは SqlClient の標準的な使用法であり、問題はありません。エラーのスタック トレースは次のとおりです。
AspDotNetStorefront.ASPDNSFProfileProvider で System.Data.SqlClient.SqlDataReader.GetOrdinal(String name) で System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName) で System.IndexOutOfRangeException が発生しました。 System.Configuration.SettingsBase.GetPropertyValueByName(String propertyName) で System.Configuration.SettingsBase.GetPropertyValueByName(String propertyName) で System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider プロバイダー) で AspDotNetStorefront.ASPDNSFProfileProvider.GetPropertyValues(SettingsContext コンテキスト、SettingsPropertyCollection settingsProperties) System.Web.Profile.ProfileBase.GetInternal(String propertyName) で (String propertyName) System.Web.Profile.ProfileBase.get_Item(String propertyName) で System.Web.Profile.ProfileBase.GetPropertyValue(String propertyName) で AspDotNetStorefront.SkinBase.OnPreInit(EventArgs e) で System.Web.UI.Page.PerformPreInit() で System.Web.UI.Page.ProcessRequestMain (ブール値 includeStagesBeforeAsyncPoint、ブール値 includeStagesAfterAsyncPoint)
サイトがクラッシュした場合、IIS を再起動して元に戻す必要があります。.NET 3.5 および SQL 2008 を搭載した Windows Server 2008 上にあり、すべて最新です。マシンは 64 ビットで、SQL Server では 32 ビット モードが有効になっており、「クラシック パイプライン モード」を使用するアプリケーション プールもあります。接続文字列は
<add name="PrimaryConnectionString" connectionString="data source=XXXX;database=XXXX;Integrated Security=True;Application Name=XXXX;MultipleActiveResultSets=true" />
どんな助けでも大歓迎です!!