加載視圖模型提供了緩存MVVM燈中沒有的IDataErrorInfo類型

[英]Loading view model gives IDataErrorInfo Type not found in cache MVVM light


I have been banging my head against this one for a while.

我一直在用頭撞牆。

I have a WPF project using MVVM-Light that suddenly is giving me errors when I try to load a certain view model.

我有一個使用mvm - light的WPF項目,當我試圖加載某個視圖模型時,它會突然出現錯誤。

In this project I have a viewmodel locator that defines the view model as follows:

在這個項目中,我有一個viewmodel定位器,它定義了視圖模型如下:

ServiceLocator.SetLocatorProvider(Function() SimpleIoc.Default)
''all other dependent services are registered before this view model
SimpleIoc.Default.Register(Of ChangeAddViewModel)()

Public ReadOnly Property ChangeAdd_VM() As ChangeAddViewModel
   Get
      Return ServiceLocator.Current.GetInstance(Of ChangeAddViewModel)()
   End Get
End Property

Then in "parent" view I call this viewmodel and assign it to a tab:

然后在“父”視圖中,我調用這個viewmodel並將其分配給一個選項卡:

Return _Locator.ChangeAdd_VM

When I try and return the above line I get the following error :

當我嘗試返回上面的代碼時,我得到了以下錯誤:

Message = "Exception has been thrown by the target of an invocation."

消息=“被調用的目標拋出異常”。

InnerException = {"Type not found in cache: System.ComponentModel.IDataErrorInfo."}

InnerException ={"類型在緩存中沒有找到:system . component . idataerrorinfo。"

StackTrace = " at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)" & vbCrLf & " at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)" & vbCrLf ...

StackTrace = " at System.RuntimeMethodHandle. "InvokeMethod(對象目標,對象[]參數,簽名sig,布爾構造函數)"系統。反射。runtimemethodinfo。UnsafeInvokeInternal(對象obj,對象[]參數,對象[]參數)"& vbCrLf……

TargetSite = {System.Object InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)}

TargetSite = {系統。對象InvokeMethod(系統。對象,系統。對象[],系統。簽名,布爾型)}

Notice the "Type not found in cache: System.ComponentModel.IDataErrorInfo."

注意“在緩存中沒有找到的類型:System.ComponentModel.IDataErrorInfo”。

I use the IDataErrorInfo to provide validation to form fields in the views. I have more than 12 other views with the same set up that are all working.

我使用IDataErrorInfo提供對視圖中的表單字段的驗證。我有超過12個具有相同設置的視圖,它們都在工作。

I have even compared the constructor of the problem viewModel to confirm its dependencies all work:

我甚至比較了問題視圖模型的構造函數來確定它的依賴關系,所有的工作:

Public Sub New(NavService As Navigation.INavigationService,
    JobService As IJobDataService,
    UserService As IUserService,
    EmployeeService As IEmployeeDataService,
    ClientService As IClientDataService,
    ModelService As IModelService,
    ErrorService As IErrorHandling,
    dialogService As IDataErrorInfo)

    _NavigationService = NavService
    _UserService = UserService
    _ModelService = ModelService
    _errorService = ErrorService
    _employeeService = EmployeeService
    _clientservice = ClientService
    _dialogService = dialogService

There are other viewModels in the project with identical constructor dependencies that are working just fine. Also, all these dependencies are registered before the viewModel is registered in the viewModelLocator

在項目中還有其他視圖模型,它們的構造函數依賴關系非常好。此外,所有這些依賴項都是在viewModelLocator中注冊viewModel之前注冊的

WHAT I TIRED:

I have looked at other Type not found in cache questions related to MVVM-Light and I have tried

我已經查看了與MVVM-Light相關的緩存問題中沒有找到的其他類型,我已經嘗試過了。

  1. making sure that all projects in solution have reference to system.ComponentModel.IDataErrorInfo
  2. 確保解決方案中的所有項目都引用system.ComponentModel.IDataErrorInfo
  3. Restarted Visual Studio many times
  4. 多次重啟Visual Studio
  5. Deleted Obj folder and forced a rebuild of the solution.
  6. 刪除Obj文件夾並強制重新構建解決方案。
  7. Tried manually adding IDataErrorInfo to the ViewModelLocator but I couldn't get it to work because I don't have a custom implementation of it and have no class to register to the interface.
  8. 嘗試手工向ViewModelLocator添加IDataErrorInfo,但是我無法讓它工作,因為我沒有對它的自定義實現,也沒有要注冊到接口的類。
  9. I reviewed the git history for this file's history of changes, and no changes were made to this file for months, but this problem appeared in the last week.
  10. 我檢查了這個文件的變更歷史的git歷史,幾個月來沒有對這個文件做任何修改,但是這個問題在上周出現了。

QUESTION:

Can someone help me figure out why only one of my views/viewModels gives the error Type not found in cache: System.ComponentModel.IDataErrorInfo when being created.

有人能幫我找出為什么只有我的一個視圖/視圖模型給出了在緩存中沒有找到的錯誤類型:System.ComponentModel。IDataErrorInfo時創建的。

Thanks in advance

謝謝提前

J

J

1 个解决方案

#1


0  

Stupid mistake

愚蠢的錯誤

The following line in the constructor:

構造函數中如下一行:

dialogService As IDataErrorInfo

should be:

應該是:

dialogService As IDialogService

The error made it so clear, sometimes you get so blind to your own projects

這個錯誤很明顯,有時你會對自己的項目視而不見


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2017/08/27/724f218591c9a6bf22630460b928e553.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com