please delete me
please delete me

Reputation:

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.

Upvotes: 27

Views: 21149

Answers (7)

Baraka Ally
Baraka Ally

Reputation: 19

I faced this problem , i solved it by click app.config to open it and leave it ,then go to properties and upgrade .NET version

Upvotes: 1

jwatts1980
jwatts1980

Reputation: 7356

For me, my project was using a web.config file that was a linked file back to a web.config in another project. I removed the link, changed the target, then added the link back.

Upvotes: 1

sirdank
sirdank

Reputation: 3581

I was trying to retarget from .NET 4.5.2 to .NET 4.5 In my app.config, I had to change

<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />

to

<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />

before the project properties page would let me retarget.

Upvotes: 0

jocull
jocull

Reputation: 21125

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

Upvotes: 30

arpan desai
arpan desai

Reputation: 909

I have same issue. I solved it by removing write protected attribute of web.config file. It was read only earlier.

Upvotes: 1

Idan P
Idan P

Reputation: 275

For me the problem was the web.config file located outside of the project directory. I moved it back in, and was able to change the target framework.

Upvotes: 1

please delete me
please delete me

Reputation:

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>

Upvotes: 22

Related Questions