2015-01-07 6 views
2

그래서 약간의 머리를 긁는 사람이 있는데 도움이 필요합니다. 우리는 최근 .NET 3.5, Win 2003 및 SQL 2008의 ASP.Net 웹 폼 앱을 .Net 4.5, Win 2008 및 SQL 2012로 이전했습니다.이 앱은 4 년 이상 오래된 플랫폼에서 아무런 문제없이 실행되었습니다. 새 플랫폼에서는 일시적인 문제로 인해 충돌이 발생합니다. 우리는 오류 트래핑을 추가하여 문제가 정확히 어디에서 발생했는지, 그리고 우리가보고있는 것이 어떤 의미가 없는지를 찾아 냈습니다. 우리가 채우기를 사용하는SqlDataAdapter 채우기는 NULL 기본 키를 제공합니다.

Select 
    ItemKey 
From Items 
Where ItemParentKey = @Key 

Create Table Items 
(
    ItemKey int identity(1,1) not null 
    ,ItemParentKey int 
    ,constraint PK_Items primary key clustered (ItemKey) 
) 

그물 측면에서 : 오류를 던지는

라인은 지정된 상위 키와 관련된 기본 키의 목록을 얻을 수있는 테이블을 쿼리 우리 DAL,에 메서드를 호출하여 위의 select 문을 포함하는 저장 프로 시저를 호출하고 결과를 데이터 테이블에로드합니다. 우리가 데이터 테이블의 행을 반복하고 키를 사용하여 무언가를 수행하려고 할 때 오류가 발생합니다. 모든 키가 null이므로 잘못된 캐스트 예외가 발생합니다. 데이터 테이블은 Key라는 단일 정수 열이있는 xsd 파일에 정의됩니다.

Adapter.Fill(data); 
foreach(KeyListRow Row in data.KeyList) 
{ 
    Item.Children.Add(Row.Key); //Invalid cast exception 
} 

는 디자이너가 강력한 형식의 열을 변환하는 동안 예외를 발생 코드를 생성 실제로 있음을 알아 두셔야합니다, 우리가 할 수있는 곳이 그것을 잡을 수 있습니다.

try catch를 사용하고 쿼리 매개 변수 및 결과의 세부 정보를 기록하는 코드를 추가하면 쿼리가 매개 변수 값에 대한 올바른 행 수를 반환하지만 모두 null로 돌아갑니다. 위의 쿼리 및 테이블 정의에서 가능하지 않음)

몇 가지 다른 점은 간헐적이며 몇 일 또는 몇 주 동안 문제없이 작동 한 다음 1 시간마다 충돌합니다. 저장 프로 시저를 수동으로 실행하고 앱이 다운 된 동안 오류를 일으키는 레코드의 데이터를 검사하면 앱이 로그의 결과로보고하는 값이 아닌 예상 값을 보여줍니다. 사이트의 응용 프로그램 풀을 다시 시작하면 문제가 해결되고 다시 시작될 때까지 다시 연결됩니다. 트래픽 수준과 앱이 얼마나 자주 다운 되나간에 약간의 상관 관계가있는 것으로 보이지만 아직까지 구체적으로 파악할 수있는 것은 없습니다.

가능한 원인이나 추가 조사 방법에 대한 제안 사항이 있으십니까?


편집 2015년 3월 16일

예외 정보 :

예외 유형 - ExceptionMessage (내부 예외를 드릴)

  1. System.Web.HttpUnhandledException - 유형의 예외 ' System.Web.HttpUnhandledException '이 발생했습니다.
  2. System.Data.StrongTypingException - 'KeyList'테이블의 'Key'열의 값이 DBNull입니다.
  3. System.InvalidCastException - 지정된 캐스트가 유효하지 않습니다.

데이터는 반환 :

data.KeyList.Count : 7;
data.KeyList [0].키 : NULL;
data.KeyList [1] .Key : NULL;
data.KeyList [2] .Key : NULL;
data.KeyList [3] .Key : NULL;
data.KeyList [4] .Key : NULL;
data.KeyList [5] .Key : NULL;
data.KeyList [6] .Key : NULL;

디자이너 생성 코드 :

public partial class dsXXXX : global::System.Data.DataSet 
{ 

    private KeyListDataTable tableKeyList; 

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
    [global::System.ComponentModel.Browsable(false)] 
    [global::System.ComponentModel.DesignerSerializationVisibility(global::System.ComponentModel.DesignerSerializationVisibility.Content)] 
    public KeyListDataTable KeyList { 
     get { 
      return this.tableKeyList; 
     } 
    } 

    /// <summary> 
    ///Represents the strongly named DataTable class. 
    ///</summary> 
    [global::System.Serializable()] 
    [global::System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedTableSchema")] 
    public partial class KeyListDataTable : global::System.Data.TypedTableBase<KeyListRow> { 

     private global::System.Data.DataColumn columnKey; 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     public KeyListDataTable() { 
      this.TableName = "KeyList"; 
      this.BeginInit(); 
      this.InitClass(); 
      this.EndInit(); 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     internal KeyListDataTable(global::System.Data.DataTable table) { 
      this.TableName = table.TableName; 
      if ((table.CaseSensitive != table.DataSet.CaseSensitive)) { 
       this.CaseSensitive = table.CaseSensitive; 
      } 
      if ((table.Locale.ToString() != table.DataSet.Locale.ToString())) { 
       this.Locale = table.Locale; 
      } 
      if ((table.Namespace != table.DataSet.Namespace)) { 
       this.Namespace = table.Namespace; 
      } 
      this.Prefix = table.Prefix; 
      this.MinimumCapacity = table.MinimumCapacity; 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     protected KeyListDataTable(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) : 
       base(info, context) { 
      this.InitVars(); 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     public global::System.Data.DataColumn KeyColumn { 
      get { 
       return this.columnKey; 
      } 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     [global::System.ComponentModel.Browsable(false)] 
     public int Count { 
      get { 
       return this.Rows.Count; 
      } 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     public KeyListRow this[int index] { 
      get { 
       return ((KeyListRow)(this.Rows[index])); 
      } 
     } 

     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     public event KeyListRowChangeEventHandler KeyListRowChanging; 

     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     public event KeyListRowChangeEventHandler KeyListRowChanged; 

     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     public event KeyListRowChangeEventHandler KeyListRowDeleting; 

     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     public event KeyListRowChangeEventHandler KeyListRowDeleted; 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     public void AddKeyListRow(KeyListRow row) { 
      this.Rows.Add(row); 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     public KeyListRow AddKeyListRow(int Key) { 
      KeyListRow rowKeyListRow = ((KeyListRow)(this.NewRow())); 
      object[] columnValuesArray = new object[] { 
        Key}; 
      rowKeyListRow.ItemArray = columnValuesArray; 
      this.Rows.Add(rowKeyListRow); 
      return rowKeyListRow; 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     public override global::System.Data.DataTable Clone() { 
      KeyListDataTable cln = ((KeyListDataTable)(base.Clone())); 
      cln.InitVars(); 
      return cln; 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     protected override global::System.Data.DataTable CreateInstance() { 
      return new KeyListDataTable(); 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     internal void InitVars() { 
      this.columnKey = base.Columns["Key"]; 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     private void InitClass() { 
      this.columnKey = new global::System.Data.DataColumn("Key", typeof(int), null, global::System.Data.MappingType.Element); 
      base.Columns.Add(this.columnKey); 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     public KeyListRow NewKeyListRow() { 
      return ((KeyListRow)(this.NewRow())); 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     protected override global::System.Data.DataRow NewRowFromBuilder(global::System.Data.DataRowBuilder builder) { 
      return new KeyListRow(builder); 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     protected override global::System.Type GetRowType() { 
      return typeof(KeyListRow); 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     protected override void OnRowChanged(global::System.Data.DataRowChangeEventArgs e) { 
      base.OnRowChanged(e); 
      if ((this.KeyListRowChanged != null)) { 
       this.KeyListRowChanged(this, new KeyListRowChangeEvent(((KeyListRow)(e.Row)), e.Action)); 
      } 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     protected override void OnRowChanging(global::System.Data.DataRowChangeEventArgs e) { 
      base.OnRowChanging(e); 
      if ((this.KeyListRowChanging != null)) { 
       this.KeyListRowChanging(this, new KeyListRowChangeEvent(((KeyListRow)(e.Row)), e.Action)); 
      } 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     protected override void OnRowDeleted(global::System.Data.DataRowChangeEventArgs e) { 
      base.OnRowDeleted(e); 
      if ((this.KeyListRowDeleted != null)) { 
       this.KeyListRowDeleted(this, new KeyListRowChangeEvent(((KeyListRow)(e.Row)), e.Action)); 
      } 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     protected override void OnRowDeleting(global::System.Data.DataRowChangeEventArgs e) { 
      base.OnRowDeleting(e); 
      if ((this.KeyListRowDeleting != null)) { 
       this.KeyListRowDeleting(this, new KeyListRowChangeEvent(((KeyListRow)(e.Row)), e.Action)); 
      } 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     public void RemoveKeyListRow(KeyListRow row) { 
      this.Rows.Remove(row); 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { 
      global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); 
      global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); 
      dsXXXX ds = new dsXXXX(); 
      global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); 
      any1.Namespace = "http://www.w3.org/2001/XMLSchema"; 
      any1.MinOccurs = new decimal(0); 
      any1.MaxOccurs = decimal.MaxValue; 
      any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; 
      sequence.Items.Add(any1); 
      global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); 
      any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; 
      any2.MinOccurs = new decimal(1); 
      any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; 
      sequence.Items.Add(any2); 
      global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); 
      attribute1.Name = "namespace"; 
      attribute1.FixedValue = ds.Namespace; 
      type.Attributes.Add(attribute1); 
      global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); 
      attribute2.Name = "tableTypeName"; 
      attribute2.FixedValue = "KeyListDataTable"; 
      type.Attributes.Add(attribute2); 
      type.Particle = sequence; 
      global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); 
      if (xs.Contains(dsSchema.TargetNamespace)) { 
       global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); 
       global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); 
       try { 
        global::System.Xml.Schema.XmlSchema schema = null; 
        dsSchema.Write(s1); 
        for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { 
         schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); 
         s2.SetLength(0); 
         schema.Write(s2); 
         if ((s1.Length == s2.Length)) { 
          s1.Position = 0; 
          s2.Position = 0; 
          for (; ((s1.Position != s1.Length) 
             && (s1.ReadByte() == s2.ReadByte()));) { 
           ; 
          } 
          if ((s1.Position == s1.Length)) { 
           return type; 
          } 
         } 
        } 
       } 
       finally { 
        if ((s1 != null)) { 
         s1.Close(); 
        } 
        if ((s2 != null)) { 
         s2.Close(); 
        } 
       } 
      } 
      xs.Add(dsSchema); 
      return type; 
     } 
    } 

    /// <summary> 
    ///Represents strongly named DataRow class. 
    ///</summary> 
    public partial class KeyListRow : global::System.Data.DataRow { 

     private KeyListDataTable tableKeyList; 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     internal KeyListRow(global::System.Data.DataRowBuilder rb) : 
       base(rb) { 
      this.tableKeyList = ((KeyListDataTable)(this.Table)); 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     public int Key { 
      get { 
       try { 
        return ((int)(this[this.tableKeyList.KeyColumn])); 
       } 
       catch (global::System.InvalidCastException e) { 
/*****Exception is thrown here*****/ 
        throw new global::System.Data.StrongTypingException("The value for column \'Key\' in table \'KeyList\' is DBNull.", e); 
       } 
      } 
      set { 
       this[this.tableKeyList.KeyColumn] = value; 
      } 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     public bool IsKeyNull() { 
      return this.IsNull(this.tableKeyList.KeyColumn); 
     } 

     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")] 
     public void SetKeyNull() { 
      this[this.tableKeyList.KeyColumn] = global::System.Convert.DBNull; 
     } 
    } 

} 
+0

내부 예외를 포함하여 전체 예외를 게시하십시오. 예외를 캡쳐 한 후'ex.ToString()'을 게시하십시오. 또한 'KeyTableRow'는 무엇입니까? 사실 C# 코드에서 사용하는 모든 유형의 정의는 무엇입니까? 마지막으로,'var key = Row.Key;/* newline */Item.Children.Add (key);'그리고 어떤 줄이 끊어지는 지 봅니다. –

+0

@ 존 우리는 그 모든 작업을 완료했습니다. 원래 언급했듯이 테이블 행은 데이터 집합 (xsd) 파일에 정의 된 데이터 테이블입니다. 이것은 열이 int로 정의 된 단일 열 테이블입니다. 디자이너가 생성 한 코드에서 원시 DB 결과를 강력한 형식의 int로 캐스팅하려고 시도하면 예외가 발생합니다. 나는 계속해서 전체 예외 스택에 대한 예외 유형과 메시지 정보를 추가했으며 디버깅 코드에 의해 게시물에 기록되는 값도 함께 표시했습니다. – Rozwel

+0

7 개의 행이 반환 될 것으로 예상됩니까? 그렇다면 그것은 큰 단서입니다. 테이블의 열 이름이'ItemKey'이지만'DataTable'의 열 ​​이름이'Key' 인 것은 의심 스럽습니다. 나는 당신이 올바른 7 개의 행을 가져 왔다고 의심하지만, 찾고있는'ItemKey'는 당신의 테이블에 갈 곳이 없다. –

답변

0
우리는이 문제의 정확한 원인을 결코하지 않았다

, 그러나 우리의 서버 팀은 다른 서버에 다른 응용 프로그램을 이동이 하나 다시 행동을 시작했다. 그래서 모든 지표는 우리가 어떤 형태의 자원 기아 또는 이와 유사한 갈등을 다루고 있다는 것입니다.