Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2010 : Can't change target. Gives TargetFrameworkMoniker Error

I have a console application which has target .NET 2.0

It is very short but full of unsafe code.

I converted it to VS 2010. I run it OK.

When I try to change "target framework" in properties to 3.5 or 4.0 it shows message box:

TargetFrameworkMoniker: Error parsing application configuration file at line 0. XML document must have a top level element.

the target then stays 2.0 anyway.


2 Answers

This happened to me because my project file was marked as "Read Only" in its properties. Changed it, and it was fine.

It also could be caused by read-only app.config/web.config

like image 93
jocull Avatar answered Sep 11 '25 01:09

jocull


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>