简体   繁体   中英

Unrecognized attribute ‘targetframework’ when debugging in Visual Studio

Although there are several questions and answers about the "Unrecognized attribute 'targetframework'" error, the other questions mainly have to do with errors deploying to a server, and so the answers show IIS 7 settings that need changing. In my case, I was getting the "Unrecognized attribute 'targetframework'" error when trying to debug in Visual Studio.

I manually modified my web.config file to upgrade it to 4.0, as described in this MSDN article . That included adding the targetFramework attribute to my compilation tag, like this:

    <compilation debug="true" targetFramework="4.0">

I did this because I wanted to use an assembly that targeted the 4.0 framework. But then when I tried to debug the site, I received the "Unrecognized attribute 'targetframework'" error. As I mentioned, the solutions that I found all talked about changing the application pool in IIS 7, but I was just trying to run the site in the Visual Studio debugger. I tried looking at the Properties for the Solution, but didn't find anything about the framework.

It took me a lot longer than it should have, but eventually I found the other Properties dialog I was looking for. It wasn't in the Solution Properties, but was in the site "Property Pages", in the Build section.

To open the Property Pages dialog, you can do any of these:

  • go to View > Property Pages, or

  • go to Debug > [My Site] Properties... (last item in Debug menu), or

  • Right-click on the Web Site in the Solution Explorer (2nd item in Solution Explorer, under the solution itself) and choose Property Pages

启动属性页的菜单

Then in the dialog that pops up, click the Build section on the left. The right side will then contain a drop down box for "Target Framework". When you change it to 4.0, Visual Studio will warn you that the project will be reloaded. After that, it will debug properly.

框架设定

我遇到了同样的问题。...我从MS Source safe那里克隆了一个解决方案,在VS 2015中打开了该解决方案。试图注册dot.net Framework 4.0。进行项目设置-> Web将IIS Express端口http:// localhost:59563 /更改为类似http:// localhost:59569的内容,或检查Override应用程序的根URL

I encountered this issue when I used the Visual Studio interfaces to change the .NET version but then reverted the changed files. To resolve, I closed Visual Studio and deleted the.vs folder from the project. Visual Studio rebuilds this with the appropriate information when the project is rebuilt.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM