为什么我的 .NET 4 目标应用程序需要安装 2.0 才能运行?
我有一个使用 .NET 3.5 构建的非常复杂的 WPF 和 C++/CLI 应用程序。我们已迁移到 4.0 以利用 WPF 的优点,因此解决方案中的所有项目都以 4.0 为目标。
在仅安装 4.0(和 MSVC++ 2010 [和 2008])的 XP 计算机上运行我们的应用程序时,将弹出一个错误对话框,其中包含以下消息:
“要运行此应用程序,您首先必须安装以下版本的 .NET Framework 之一:2.0.50727”
如果我用.NET 4.0安装.NET 2.0,我的应用程序将运行。
有人知道如何调试加载程序集以了解发生了什么情况吗?
更新
我刚刚发现了 VS2010 中的“模块”窗口,并且在调试器中运行时还观察了输出窗口中的模块加载事件。我可以清楚地看到有一个 .NET 2.0 模块与我的应用程序一起运行。
'Kudu.exe': Loaded 'C:\Windows\SysWOW64\WindowsCodecs.dll', Exports loaded.
'Kudu.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll', Exports loaded.
'Kudu.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4927_none_d08a205e442db5b5\msvcr80.dll', Exports loaded.
有什么方法可以查看加载的内容吗?
I have a pretty complex WPF and C++/CLI application that was built using .NET 3.5. We've migrated to 4.0 to take advantage of the WPF goodies, so all our projects in the solution are targeting 4.0.
On running our application on XP machines with just 4.0 (and MSVC++ 2010 [and 2008]), an error dialog will pop up with the message:
"To run this application, you first must install one of the following version of the .NET framework: 2.0.50727"
If I go install .NET 2.0 with .NET 4.0 my application will run.
Anyone know how to debug loading the assemblies to find out what's going on?
UPDATE
I just found out about the "Modules" window in VS2010, and also watched the Modules loaded events in the output window when running in the debugger. I can clearly see there's a single .NET 2.0 module running with my application.
'Kudu.exe': Loaded 'C:\Windows\SysWOW64\WindowsCodecs.dll', Exports loaded.
'Kudu.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll', Exports loaded.
'Kudu.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4927_none_d08a205e442db5b5\msvcr80.dll', Exports loaded.
Is there any way to see what loaded this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,我放弃了,从启动开始逐行执行代码,直到遇到模块加载语句。不,感谢 VS2010 糟糕的调用堆栈和无端断点,这是我对现在已弃用的 StrongName.h 函数的引用,我用它来验证我们的程序集。
.NET 4 现在使用 MetaHost.h 和 ICLRStrongName 函数。
确实需要有一个关于此的编译器警告。
Okay I gave up and stepped through my code line by line from startup until I hit the module loading statements. No thanks to VS2010's terrible call stack and thanks to gratuitous break points, it was my reference to a now deprecated StrongName.h functions that I use to verify our assemblies.
.NET 4 now uses MetaHost.h and ICLRStrongName functions.
There REALLY needs to be a compiler warning about this.
检查解决方案中每个项目的目标框架。
另外,检查对象浏览器的“我的解决方案”视图并确保您没有看到
mscorlib [2.0.0.0]
。您也可能引用为 .Net 2.0 编译的单独 DLL。
Check the target framework of every project in your solution.
Also, check the Object Browser's My Solution view and make sure you don't see
mscorlib [2.0.0.0]
.It's also possible that you're referencing a separate DLL that was compiled for .Net 2.0.