2015-11-02 61 views
-2

我不斷收到System.Reflection.TargetInvocationException在構造

System.Reflection.TargetInvocationException

和PresentationFramework.dll,其他信息異常已通過調用的目標引發異常。

有人可以幫我在這裏嗎?

信息: 調用堆棧

PresentationFramework.dll System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader xamlReader,System.Xaml.IXamlObjectWriterFactory writerFactory,布爾skipJournaledProperties,對象rootObject,系統! .Xaml.XamlObjectWriterSettings設置的System.Uri基本URI)未知

namespace PMD.Analysis.AnalysisViewModel 
     { 
      using PMD.Measurement.MeasurementModel; 
      using System.Windows.Data; 
      using PMD.Analysis.AnalysisModel; 
      using System; 
      using System.Collections.Generic; 
      using PMD.Measurement.MeasurementViewModel; 
      public class AnalysisViewModel : ViewModel 
      { 

     /// <summary> 
     /// New analysis command. 
     /// </summary> 
     private ICommand newAnalysis = null; 
     public PMD.Analysis.AnalysisViewModel.NewAnalysisViewModel m_NewAnalysisViewModel; 
     Measurement measurement = new Measurement(); 
     private ICollectionView measurements = null; 
     /// <summary> 
     /// Measurement's search by title field. 
     /// </summary> 
     private string searchTitle; 
     /// <summary> 
     /// Measurement's search by title field. 
     /// </summary> 
     private string searchTester; 
     /// <summary> 
     /// Measurement's search by vehicle VIN field. 
     /// </summary> 
     private string searchVehicleVIN; 

     public MeasurementModel MeasurementModel 
     { 
      get; 
      set; 
     } 


     public enum SelectedState 
     { 
      // No Masurements. 
      Inactive, 
      // Masurements. 
      Active, 
      // Waiting for Masurements. 
      WaitingAnswer 
     }; 


     public SelectedState CurrentSelectedState { get; set; } 

     public Analysis Analysis 
     { 
      get; 
      set; 
     } 

     public AnalysisViewModel() 
     { 

      Analysis = new Analysis(); 
      measurements = new ListCollectionView(MeasurementModel.Measurements); 
      measurements.Filter = new Predicate<object>(SearchCallbackAnalysis); 
     } 

     ~AnalysisViewModel() 
     { 

     } 

     /// <summary> 
     /// List of measurements that will be displayed in analysis view. 
     /// </summary> 
     public ICollectionView Measurements 
     { 
      get { return measurements; } 

      set { measurements = value; } 
     } 

     /// <summary> 
     /// Gets or sets new analysis command. 
     /// </summary> 
     public ICommand NewAnalysis 
     { 
      get 
      { 
       if (newAnalysis == null) 
        newAnalysis = new NewAnalysisCommand(this); 
       return newAnalysis; 
      } 
     } 


     public bool SearchCallbackAnalysis(object item) 
     { 
      bool isItemShowed = true; 
      if ((searchTitle != "") && (searchTitle != null)) 
       isItemShowed &= (((Measurement)item).Title == searchTitle); 
      if ((searchVehicleVIN != "") && (searchVehicleVIN != null)) 
       isItemShowed &= (((Measurement)item).Vehicle.VehicleVIN == searchVehicleVIN); 
      if ((SearchTester != "") && (SearchTester != null)) 
       isItemShowed &= (((Measurement)item).Tester == SearchTester); 
      return isItemShowed; 
     } 



     /// <summary> 
     /// Gets or sets measurement's search by title field. 
     /// </summary> 
     public string SearchTitle 
     { 
      get 
      { 
       return searchTitle; 
      } 

      set 
      { 

       searchTitle = value; 
       Measurements.Refresh(); 
      } 
     } 

     /// <summary> 
     /// Gets or sets measurement's search by tester name field. 
     /// </summary> 
     public string SearchTester 
     { 
      get 
      { 
       return searchTester; 
      } 

      set 
      { 

       searchTester = value; 
       Measurements.Refresh(); 
      } 
     } 

     /// <summary> 
     /// Gets or sets measurement's search by vehicle VIN field. 
     /// </summary> 
     public string SearchVehicleVIN 
     { 
      get 
      { 
       return searchVehicleVIN; 
      } 
      set 
      {  
       searchVehicleVIN = value; 
       Measurements.Refresh(); 
      } 
     }  
    }//end AnalysisViewModel 

}//end namespace AnalysisViewModel 

,如果我在構造函數中這行代碼註釋:

measurements.Filter = new Predicate<object>(SearchCallbackAnalysis); 

一切工作正常,但我需要這一行來搜索列表中。

附加信息:

xamlReader Cannot obtain value of local or argument 'xamlReader' as it is not available at this instruction pointer, possibly because it has been optimized away. System.Xaml.XamlReader 

writerFactory Cannot obtain value of local or argument 'writerFactory' as it is not available at this instruction pointer, possibly because it has been optimized away. System.Xaml.IXamlObjectWriterFactory 

skipJournaledProperties Cannot obtain value of local or argument 'skipJournaledProperties' as it is not available at this instruction pointer, possibly because it has been optimized away. bool 

rootObject Cannot obtain value of local or argument 'rootObject' as it is not available at this instruction pointer, possibly because it has been optimized away. object 

settings Cannot obtain value of local or argument 'settings' as it is not available at this instruction pointer, possibly because it has been optimized away. System.Xaml.XamlObjectWriterSettings 

baseUri Cannot obtain value of local or argument 'baseUri' as it is not available at this instruction pointer, possibly because it has been optimized away. System.Uri 
+1

我認爲我們需要更多的信息,你可以添加完整的異常堆棧和完整的異常消息和內部消息嗎?我不認爲問題出在Predicate的構造函數上。你可以在SearchCallbackAnalysis上添加一個斷點嗎? – tire0011

+0

已添加一個斷點到SearchCallbackAnalysis我得到異常之前調用SearchCallbackAbalysis。但我在其他課程和作品中使用這種方法。我把斷點在測量=新的ListCollectionView(MeasurementModel.Measurements);並且我仍然有異常 – user3223293

+0

此異常的源信息不可用或者從此模塊的調試信息中缺少 – user3223293

回答

0

我有嘗試:

public ICollectionView Measurements 
     { 
      get { return measurements; } 

      set { measurements = value; 
measurements.Filter = new Predicate<object>(SearchCallbackAnalysis); 
} 
     } 

現在一切工作正常。謝謝你試圖幫助我。