升级到.NET 4.5,现在“值不落在预期范围内". [英] Upgraded to .NET 4.5, now "value does not fall within the expected range"

查看:86
本文介绍了升级到.NET 4.5,现在“值不落在预期范围内".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到一个错误框弹出窗口,提示 TargetFrameworkMoniker:值不在预期范围内.我正在使用 VisualStudio 2012 .这是一个Windows窗体应用程序.我四处搜寻,发现当表单中的元素具有重复名称时会出现此错误,而我的表单则没有.我已经升级了解决方案中的所有其他项目,这是最后一个.

I am getting an error box popup that says TargetFrameworkMoniker: value does not fall within the expected range. I am using VisualStudio 2012. This is a windows form application. I have searched around and have found hat this error shows up when an element in the form has a duplicate name, which my form does not. I have upgraded all other projects in my solution and this is the last one.

复制步骤:

  1. 右键单击项目,然后转到应用程序中的属性标签

  1. Right click on the project and go to properties in the application tab

将目标框架从.NET Framework 4更改为.NET Framework4.5

Change the Target framework from .NET Framework 4, to .NET Framework 4.5

在询问我是否真的确定的框中单击是".

Click Yes on the box that asks me if I am really sure.

错误消息弹出.

我不确定如何使用stacktrace查找真正的错误.

I am not sure how to find the real error with stacktrace.

有人有什么建议吗?

推荐答案

在VS 2017和VS 2019中仍然会发生这种情况,例如,当您从Framework 4.5转到4.5.2或类似的东西时.它可能发生在任何类型的项目中,通常是当您有一个或多个引用的项目要逐个更新到新的.NET版本时.

This still happens in VS 2017 and VS 2019, for instance when you go from Framework 4.5 to 4.5.2 or something similar. It can happen to any type of project, and usually when there are one or more referenced projects that you are updating one by one to a new .NET version.

原因如下:系统会在相应文件中更新框架的版本并将其保存到磁盘,但是在尝试关闭/重新打开项目后,脏标志仍然会以某种方式设置,就像平时一样

The cause is as follows: the system updates the version of the framework in the corresponding file and saves it to disk, but somehow the dirty-flag is still set after it tries to close/reopen the project as it is usually doing.

然后,Visual Studio尝试更新内存文件,该文件已经使用新版本进行了刷新,但是它希望使用旧版本.因此出现错误:在您的情况下,它应该看到4.0,但是已经是4.5.

Visual Studio then tries to update the in-memory file, which is already refreshed with the new version, but it expects the old version to be there. Hence the error: in your case, it expected to see 4.0, but it was already 4.5.

VS中的错误从未得到修复,它是已加载的内存文件与磁盘上已存在内容之间的同步问题.

The bug in VS has never been fixed, and is a synchronization issue between the loaded an in-memory files and what's already on disk.

关闭/重新打开Visual Studio将解决此问题.卸载/重新加载(右键单击项目)单个项目也可以解决该问题.

Closing / reopening Visual Studio will solve this. Unloading / reloading (right-mouse click on project) the individual project will also solve the issue.

当您先更新引用的项目,然后再更新使用的项目时,似乎会发生这种情况.但是我无法在所有情况下都持续进行再现.

This seems to happen when you update a referenced project first, and then the using project. But I couldn't consistently repro it in all scenarios.

与您提到的某些博客文章中解释的重复名称"情况无关.

It has nothing to do with the 'duplicate name' situation explained in some blog posts that you referred to.

这篇关于升级到.NET 4.5,现在“值不落在预期范围内".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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