Visual Studio 2010:无法更改目标.给出 TargetFrameworkMoniker 错误 [英] Visual Studio 2010 : Can't change target. Gives TargetFrameworkMoniker Error
问题描述
我有一个面向 .NET 2.0 的控制台应用程序
I have a console application which has target .NET 2.0
它很短,但充满了不安全的代码.
It is very short but full of unsafe code.
我将其转换为 VS 2010.我运行正常.
I converted it to VS 2010. I run it OK.
当我尝试将属性中的目标框架"更改为 3.5 或 4.0 时,它显示消息框:
When I try to change "target framework" in properties to 3.5 or 4.0 it shows message box:
TargetFrameworkMoniker:在第 0 行解析应用程序配置文件时出错.XML 文档必须具有顶级元素.
TargetFrameworkMoniker: Error parsing application configuration file at line 0. XML document must have a top level element.
目标仍然是 2.0.
推荐答案
找到了解决方案.只需在文本键盘中打开 app.config(由于某种原因它是空的)并粘贴:
Found the solution. Simply opened app.config in text pad (it was empty for some reason) and pasted:
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
这篇关于Visual Studio 2010:无法更改目标.给出 TargetFrameworkMoniker 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!