【发布时间】:2013-03-18 17:05:07
【问题描述】:
这是我第一次在 StackOverflow 上发帖(虽然它在过去帮了我很多)而且通常我什至不必发帖,因为我假设的问题已经回答了。但是这个我真的找不到合适的解释。
所以我在修改 C#、Entity Framework 4、WPF 和 MVVM Light。我已经制作了一个程序集,用作各种模型、视图和视图模型的库,用于特定目的。
现在我正在制作另一个用于不同目的的组件。但是,在第一个程序集中已经提供了一些必需的方法和视图。所以我想我要将第一个程序集的引用添加到第二个程序集,然后从第一个程序集创建模型的实例到第二个程序集的模型或 ViewModel。
一切都没有错误地构建。但是当我检查第二个程序集中的视图的设计视图时,这部分有锯齿状的下划线:
<UserControl.Resources>
<vm:ViewModelLocator x:Key="Locator" />
</UserControl.Resources>
当您查看设计视图时,顶部栏上会出现一个错误,其中包含以下文字:
Object reference not set to an instance of an object.
at Powell.Materials.Common.ViewModel.MaterialsViewViewModel.SetupLists() in E:\Projects\Software\Powell Marketing\Powell\Powell\Materials\Powell.Materials.Common\ViewModel\MaterialsViewViewModel.cs:line 514
at Powell.Materials.Common.ViewModel.MaterialsViewViewModel..ctor() in E:\Projects\Software\Powell Marketing\Powell\Powell\Materials\Powell.Materials.Common\ViewModel\MaterialsViewViewModel.cs:line 601
有人遇到过这种类型的错误吗?或者有没有合适的方法来做这种事情?
【问题讨论】:
-
你能发帖
MaterialsViewViewModel.SetupLists()吗?我很确定,在那里可以找到错误。 -
private void SetupLists() { Retrieve retrieve = new Retrieve(secretKey, IDUser, connectionName); unitListProperty = retrieve.RetrieveUnits(); matlTypeProperty = retrieve.RetrieveMaterialTypes(); supplierListProperty = retrieve.RetrieveSuppliers(); }它在自己的模型中调用一个方法,该方法与来自引用程序集的模型进行通信。
标签: c# wpf mvvm entity-framework-4 mvvm-light