EntryPointNotFoundException - 在 Expression Blend 4 中加载 MVVM Light View 时未找到入口点

发布于 2024-12-16 13:16:17 字数 1822 浏览 0 评论 0原文

我发布这个问题是为了记录解决方案,因为我发现解决它非常棘手且耗时。

我正在使用Laurent Bugnion的优秀的MVVM Light Toolkit 在 Silverlight 4 项目中,我将他的 ViewModelLocator 模式与Microsoft.Practices.ServiceLocation.ServiceLocator 加载 Blendability 的设计时模型。最初在Expression Blend 4中加载视图是有效的,并且设计时数据绑定非常好。这在某个时刻停止工作,并且 Blend 中根本没有任何错误消息。

我使用 Visual Studio 2010 SP1 附加到 Blend.exe 来调试该问题。此行代码抛出 EntryPointNotFoundException(未找到入口点)异常:

return ServiceLocator.Current.GetInstance<ExampleViewModel>();

奇怪的是,我能够使用设计时数据绑定在 Visual Studio XAML 设计器中成功加载相同的视图工作正常。我使用另一个 Visual Studio 实例将调试器附加到托管 XAML 设计器的 Visual Studio 实例,并能够确认 ServiceLocator 调用已成功执行。

异常详细信息(堆栈跟踪、InnerExcetion 等)没有给我任何有关该问题的进一步线索,并且对无用错误消息的各种互联网搜索未能提供任何进一步的线索。

我最终很幸运,使用 Visual Studio 立即窗口执行导致问题的部分代码行,并收到了更好的错误消息:

?ServiceLocator.Current

类型“Microsoft.Practices.ServiceLocation.ServiceLocator”存在于“Microsoft.Practices”和“Microsoft.Practices”中.ServiceLocation.dll' 和 'Microsoft.Practices.ServiceLocation.dll'

将变更集与之前工作的代码进行比较,我注意到我添加了对GalaSoft.MvvmLight.Extras.SL4 位于单独的 Silverlight 单元测试框架 项目中(引用了用户界面项目)。此测试项目引用了 C:\Program Files (x86)\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries\Silverlight4 中的程序集,而 UI 项目则引用了 ..\packages\MvvmLightLibsPreview.4.0.0\ lib\SL4.lib我使用了 nugetMvvmLightLibsPreview 将 MVVM Light 添加到客户端项目中。

混合结果 - 错误和输出窗口在任何时候都没有显示任何错误消息。显然,不需要真正的答案,除非有一些 Blend 故障排除技术可以帮助我更快地找出问题。

I'm posting this question so I can document the solution as I found it very tricky and time consuming to solve.

I'm using Laurent Bugnion's excellent MVVM Light Toolkit in a Silverlight 4 project and I'm using his ViewModelLocator pattern with the Microsoft.Practices.ServiceLocation.ServiceLocator to load design time models for Blendability. Initially loading the Views up in Expression Blend 4 was working and the design time data binding was great. This stopped working at some point without any error message in Blend at all.

I used Visual Studio 2010 SP1 to attach to Blend.exe to debug the issue. The EntryPointNotFoundException (Entry point was not found) exception was being thrown at this line of code:

return ServiceLocator.Current.GetInstance<ExampleViewModel>();

Strangely enough, I was able to load the same View in the Visual Studio XAML Designer successfully with my design time data binding working correctly. I used another Visual Studio instance to attach the debugger to the Visual Studio instance hosting the XAML Designer and was able to confirm that the ServiceLocator call was executing successfully.

The exception detail (stack trace, InnerExcetion etc) did not give me any further clue to the problem and various Internet searches for the unhelpful error emssage failed to shed any further light.

I eventually got lucky by using the Visual Studio Immediate Window to execute part of the line of code that was causing the problem and got a much better error message:

?ServiceLocator.Current

The type 'Microsoft.Practices.ServiceLocation.ServiceLocator' exists in both 'Microsoft.Practices.ServiceLocation.dll' and 'Microsoft.Practices.ServiceLocation.dll'

Comparing the changeset to previously working code I noticed that I had added a reference to GalaSoft.MvvmLight.Extras.SL4 in a separate Unit Test Framework for Silverlight project (which references the UI project). This test project was referencing the assembly from C:\Program Files (x86)\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries\Silverlight4 where as the UI project was referencing it from ..\packages\MvvmLightLibsPreview.4.0.0\lib\SL4. I had used the nuget package MvvmLightLibsPreview to add MVVM Light to the client project.

The Blend Results - Errors and Output Windows did not show any error message at any point. Obviously there is no real answers required unless there are some Blend trouble shooting techniques which would have helped my figure out the problem faster.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

这个俗人 2024-12-23 13:16:17

我遇到了几乎相同的问题,但直到我使用 Windows 7 控制面板卸载 MVVM Light 后,问题才消失。 NuGet MVVM Light 参考仍在项目中,但现在我可以看到设计时数据。之前就已经坏掉了。

我遵循 MVVM Light 网站上的建议并附加了 Visual Studio 2012 的 Blend 预览,并收到了您上面提到的错误 (EntryPointNotFoundException)。即使那时我也不知道应该尝试删除两个相互冲突的不同版本的 MVVM Light。

I had almost the same issue though my problem did not go away until I uninstalled MVVM Light using the Windows 7 control panel. The NuGet MVVM Light references were still in the project but now I can see the design time data. It was broken before.

I followed the advice on the MVVM Light web site and attached the Blend preview for Visual Studio 2012 and received the error that you mentioned above (EntryPointNotFoundException). I had no idea even then that I should try to remove two different versions of MVVM Light that were conflicting with each other.

你怎么这么可爱啊 2024-12-23 13:16:17

正如您所期望的,更改测试项目的 MVVM Light 程序集引用以使用客户端 UI 项目使用的相同 nuget 包版本解决问题。我不知道为什么 Visual Studio 没有以与 Blend 相同的方式引用两个版本的 Microsoft.Practices.ServiceLocation.dll 的问题。

AS you would expect, changing the test project's MVVM Light assembly references to use the same nuget package versions used by the client UI Project fixes the problem. I've no idea why Visual Studio did not have a problem with two versions of the Microsoft.Practices.ServiceLocation.dll being referenced in the same way as Blend.

夜还是长夜 2024-12-23 13:16:17

我最终尝试将来自 NuGet 的包的全部内容复制到

C:\Program Files (x86)\Laurent Bugnion (GalaSoft)\Mvvm Light
工具包\二进制文件

这并没有解决问题。
由于卸载 MVVM Light 会带走代码片段等其他内容,因此我决定返回并排除更多问题。我没有成功,只能找到一个粗略的临时解决方案。

我尝试通过查看四个 DLL 文件来比较可以工作的项目和不能工作的项目:

GalaSoft.MvvmLight.Extras.WPF4 GalaSoft.MvvmLight.WPF4
Microsoft.Practices.ServiceLocation System.Windows.Interactivity

我没有看到版本有任何差异。

因此,目前的解决方法是使用 Visual Studio 2012 中的 MVVM Light WPF 模板启动一个新项目,构建它,然后删除对上述四个 DLL 的引用。然后我从 NuGet 安装 MVVM Light 包,并编辑 App.xaml 中视图模型定位器的双重条目,然后程序运行正常。此时,我可以在主窗口上看到设计数据消息,其中显示

“欢迎使用 MVVM Light [设计]”

I ended up trying to copy over the entire contents of the package that would come from NuGet into

C:\Program Files (x86)\Laurent Bugnion (GalaSoft)\Mvvm Light
Toolkit\Binaries

That did not solve the problem.
Since uninstalling MVVM Light took away other things such as snippets, I decided to go back and troubleshoot some more. I was not successful and could only find a rough temporary solution.

I tried comparing projects that would work and projects that would not work by looking at the four DLL files:

GalaSoft.MvvmLight.Extras.WPF4 GalaSoft.MvvmLight.WPF4
Microsoft.Practices.ServiceLocation System.Windows.Interactivity

I don't see any differences in versions.

So, the work around for now is to start a new project using the MVVM Light WPF template in Visual Studio 2012, build it, then remove references to the four DLL's mentioned above. Then I install the package MVVM Light from NuGet and edit out the double entry of the view model locator in App.xaml and then the program works fine. At this point I can see the design data message on the Main window which says

"Welcome to MVVM Light [design]"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文