安装 Framework 4.5 时面向 .NET Framework 4 [英] Targeting .NET Framework 4 when Framework 4.5 is installed

查看:38
本文介绍了安装 Framework 4.5 时面向 .NET Framework 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的计算机上安装了 VS2010 和 VS2012,并安装了 .NET Framework 4.0,然后我将其升级到了 .NET Framework 4.5.但是,我仍在开发需要在 .NET Framework 4.0 上运行的应用程序.该项目表示它针对 .NET Framework 4(客户端配置文件),该程序集甚至指向引用程序集下的 .NET Framework 4.0 文件夹.当我将此应用程序移动到只有 4.0 的机器时,问题就出现了,它不会启动并出现错误,直接问题是 WindowState={Binding WindowState} 导致的异常,你可以'在 4.0 中不可以,但在 4.5 中可以.我需要这个来在我的开发框上抛出异常,为什么不呢?我的假设是,尽管我尽了最大努力,它还是使用 4.5 dll(如果存在).如何在不卸载 4.5 的情况下使其真正使用 4.0?

I have VS2010 and VS2012 installed on my computer and had the .NET Framework 4.0 which I then upgraded to .NET Framework 4.5. However, I am still developing apps that need to work on .NET Framework 4.0. The project says that it is targeting .NET Framework 4 (Client Profile) the assemblies even point to .NET Framework 4.0 folder under Referenced Assemblies. The problem comes when I move this application to a machine that only has 4.0 it won't start and come up with errors the immediate problem being an exception resulting from WindowState={Binding WindowState} which you can't do in 4.0 but you can in 4.5. I need this to throw the exception on my development box, why doesn't it? My assumption is that despite my best efforts is that it uses the 4.5 dlls if they exist. How can I make it really use 4.0 without uninstall 4.5?

更新

要重现此安装 .NET Framework 4.5 并创建一个面向 .NET Framework 4.0 的 WPF 项目.将 WindowState 绑定到 VM 中的属性或隐藏的代码,使该属性具有公共获取和私有设置..NET Framework 4.5 可以很好地处理这个问题,即使 Mode=TwoWay 必须忽略设置..".在装有 .NET Framework 4.5 的盒子上,在只有 .NET Framework 4.0 的机器上试一试,它爆炸了......那么关于如何在安装 4.5 时真正定位到 4.0 有什么想法吗?

To repro this install .NET Framework 4.5 and create a WPF project targeting .NET Framework 4.0. Bind the WindowState to a property in a VM or code behind make this property have a public get and private set. .NET Framework 4.5 handles this just fine even when Mode=TwoWay must ignore the set .NET Framework 4 doesn't and throws an exception: "A TwoWay or OneWayToSource binding cannot work on the read-only property 'State' of type...". On the box with .NET Framework 4.5 works like a charm try it on a machine with only .NET Framework 4.0 and it blows up... So any ideas on how to really target 4.0 when 4.5 is installed?

在这里向 MS 报告错误:https://connect.microsoft.com/VisualStudio/feedback/details/774694/targeting-net-framework-4-0-when-4-5-doesnt-seem-to-work

Bug report to MS here: https://connect.microsoft.com/VisualStudio/feedback/details/774694/targeting-net-framework-4-0-when-4-5-doesnt-seem-to-work

推荐答案

这似乎是 .NET Framework 4.5 中的一个错误,它应该抛出异常,但安装 .NET Framework 4.5 后,您的应用程序无法运行在 .NET Framework 4.0 上,它将始终使用 4.5.

This appears to be a bug in .NET Framework 4.5 and it should throw the exception but with .NET Framework 4.5 installed there is no way to have your application run on .NET framework 4.0 it will always use 4.5.

有关更多信息,请参阅此报告的错误:http://connect.microsoft.com/VisualStudio/feedback/details/773682/wpf-property-with-private-setter-is-updated-by-a-twoway-binding

See this reported bug for more info: http://connect.microsoft.com/VisualStudio/feedback/details/773682/wpf-property-with-private-setter-is-updated-by-a-twoway-binding

这篇关于安装 Framework 4.5 时面向 .NET Framework 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆