2013-09-24 104 views
0

我有一個難題。有時我們的程序發生「xxx.DataAccess.UDT_Table_Numbers的自定義類型映射未指定或無效。」例外。重新啓動IIS服務器後,這是工作。 任何幫助將不勝感激。'xxx.DataAccess.UDT_Table_Numbers'的自定義類型映射未指定或無效

關係代碼如下:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 

using System.Data; 
using System.Configuration; 
using Oracle.DataAccess.Client; 
using Oracle.DataAccess.Types; 

using OMS.BusinessEntity.ORDValid; 
using OMS.Utilities.DBUtility; 
using OMS.Utilities.Common; 


namespace OMS.ORDValid.DataAccess 
{ 
public class ExceptionHandlingDAO 
{ 
    public string AcceptOrder(string UserID, string Customer, string OrderNo, string Exflag, string LineString, string PriorityFlag, 
              List<string> LstPrice) 
    { 
     OracleConnection conn = new OracleConnection(OracleHelper.Wistron_WOMS_ConnStr); 
     OracleCommand cmd = new OracleCommand(); 

     try 
     { 
      .... 
      string ProcedureName = "PROC_ACCEPTORDER"; 

      OracleParameter[] parmArray = { 
       new OracleParameter("v_rodno", OracleDbType.Varchar2), 
       new OracleParameter("v_customer", OracleDbType.Varchar2), 
       new OracleParameter("v_exflag", OracleDbType.Varchar2), 
       new OracleParameter("v_userid", OracleDbType.Varchar2), 
       new OracleParameter("v_highPriority", OracleDbType.Varchar2), 
       new OracleParameter("v_lineString", OracleDbType.Varchar2), 
       new OracleParameter("v_PriceList", OracleDbType.Object), 
       new OracleParameter("v_result", OracleDbType.Varchar2), 
      }; 

      parmArray[0].Value = OrderNo; 
      parmArray[1].Value = Customer; 
      parmArray[2].Value = Exflag; 
      parmArray[3].Value = UserID; 
      parmArray[4].Value = PriorityFlag; 
      parmArray[5].Value = LineString; 

      parmArray[6].UdtTypeName = "OMS.EXCEPTION_REASON"; 
      parmArray[6].Value = new UDT_Table_Numbers { Value = LstPrice.ToArray() }; 
      parmArray[7].Size = 5000; 

      parmArray[0].Direction = ParameterDirection.Input; 
      parmArray[1].Direction = ParameterDirection.Input; 
      parmArray[2].Direction = ParameterDirection.Input; 
      parmArray[3].Direction = ParameterDirection.Input; 
      parmArray[4].Direction = ParameterDirection.Input; 
      parmArray[5].Direction = ParameterDirection.Input; 
      parmArray[6].Direction = ParameterDirection.Input; 
      parmArray[7].Direction = ParameterDirection.Output; 

      foreach (OracleParameter parm in parmArray) 
      { 
       cmd.Parameters.Add(parm); 
      } 

      cmd.Connection = conn; 
      cmd.CommandText = ProcedureName; 
      cmd.CommandType = CommandType.StoredProcedure; 

      cmd.ExecuteNonQuery(); 
      string temp = cmd.Parameters["v_result"].Value.ToString(); 
      cmd.Parameters.Clear(); 
      return temp; 
     } 
     catch (Exception ex) 
     { 
      throw new Exception(ex.Message); 
     } 
     finally 
     { 
      ... 
     } 
    } 

} 

public class UDT_Table_Numbers : TableTemplate<string> 
{ 
    // Inherited from TableTemplate 
} 

// Factory to create an object for the above class 
[OracleCustomTypeMappingAttribute("OMS.EXCEPTION_REASON")] 
public class StringTableFactory : TableFactoryTemplate<UDT_Table_Numbers> 
{ 
    public override System.Array CreateStatusArray(int length) 
    { 
     OracleUdtStatus[] udtStatus = new OracleUdtStatus[length]; 
     return udtStatus; 
    } 
} 


public class TableTemplate<Type> : IOracleCustomType 
{ 
    [OracleArrayMappingAttribute()] 
    public virtual Type[] Value { get; set; } 

    public virtual void FromCustomObject(OracleConnection con, System.IntPtr pUdt) 
    { 
     if (this.Value != null) 
     { 
      OracleUdt.SetValue(con, pUdt, 0, this.Value); 
     } 
    } 

    public virtual void ToCustomObject(OracleConnection con, System.IntPtr pUdt) 
    { 
     this.Value = ((Type[])(OracleUdt.GetValue(con, pUdt, 0))); 
    } 
} 

public class TableFactoryTemplate<T> : IOracleCustomTypeFactory, IOracleArrayTypeFactory where T : IOracleCustomType, new() 
{ 
    public virtual IOracleCustomType CreateObject() 
    { 
     T obj = new T(); 
     return obj; 
    } 

    public virtual System.Array CreateArray(int length) 
    { 
     System.Type type = typeof(T).GetProperties()[0].PropertyType.GetElementType(); 
     return Array.CreateInstance(type, length); 
    } 

    public virtual System.Array CreateStatusArray(int length) 
    { 
     return null; 
    } 
} 

[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] 
public class NullableAttribute : Attribute 
{ 
} 

[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] 
public class IgnoreAttribute : Attribute 
{ 
} 
} 
+0

您可能希望爲Connection和Command對象使用塊來正確處置它們。異常處理將刪除原始異常中可能存在的所有信息。如果這不是您的意圖,請嘗試將您的異常作爲內部異常傳遞,以便稍後感興趣的相關方仍可訪問它。 – nvoigt

+0

你可以發佈完整的堆棧跟蹤嗎? – Paco

回答

0

細節堆棧跟蹤,如下: ----堆棧跟蹤---- System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(reqMsg作爲即時聊天,retMsg作爲即時聊天) (未知文件):N 4729427 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MSGDATA作爲MessageData &,類型如的Int32) (未知文件):N 01725 OMS.ORDValid.ORDValidServiceRef。 ORDValidServiceContract.BatchUpdateExcptHandling(請求作爲BatchUpdateExcptHandl ingRequest) (未知文件):N 00000 OMS.ORDValid.ORDValidServiceRef.ORDValidServiceContractClient.BatchUpdateExcptHandling(操作類型作爲字符串,CustomerString作爲字符串,ORDExceptionHDInfo方式列表1, UserID As String, Result As String&) Reference.cs: line 2532, col 13, IL 0035 OMS.ORDValid.Views.ExceptionHandlingDefaultPresenter.BatchExceptHandle(list As List 1) ExceptionHandlingDefaultPresenter.cs:線0250,列09,IL 0136 系統.Web.UI.WebControls.Button.RaisePostBackEvent(eventArgument As String) (未知文件):N 00154 System.Web.UI.Page.ProcessRequestMain(includeStagesBeforeAsyncPoint As Boolean,includeStagesAfterAsyncPoint As Boolean) (未知文件):N 03707

異常類型:System.ServiceModel.FaultException`1 [[System.ServiceModel.ExceptionDetail,System.ServiceMode l,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089]] 異常消息:'xxx.DataAccess.UDT_Table_Numbers'的自定義類型映射未指定或無效。 異常來源:mscorlib