windows 升级后“应用程序启动失败...配置不正确”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8485425/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 18:38:36  来源:igfitidea点击:

"application has failed to start ... configuration is incorrect" after upgrading?

windowsvisual-studio

提问by Tavousi

I have a project in windows application than was in VS2008. Now I convert it to VS2010. When I want to run my project, I get this message:

我在 Windows 应用程序中有一个项目,而不是在 VS2008 中。现在我将其转换为 VS2010。当我想运行我的项目时,我收到以下消息:

"This application has failed to start because the application configuration is incorrect. Review the manifest file for possible error."

“此应用程序无法启动,因为应用程序配置不正确。检查清单文件以查找可能的错误。”

How to I can run my application? Thanks.

如何运行我的应用程序?谢谢。

回答by Gopalakrishnan SA

I had the same problem where my entire C# solution was created in previous version and it did not work in new VS.Net version giving the same error. Here are a few things that will help you resolve the problem

我有同样的问题,我的整个 C# 解决方案是在以前的版本中创建的,但它在新的 VS.Net 版本中不起作用,给出了同样的错误。以下几点可以帮助您解决问题



  1. Expand the References Item and check if any item has a warning symbol attached to it.
  2. If (1) , click on References->Add Referenceand try to add the reference which has the warning. Now the warning sign has to go away.
  3. If the references displayed in 'Add reference'dialog box is grayed, you should probably get the reason by hovering next to the reference.
  4. For me it was grayed and it clearly mentioned that the component is not compatible with the current .NET Target runtime. Right click on Project -> 'Properties'and try to change the .NET Runtime and give a shot by compiling the entire solution and try to execute it.
  5. If it still fails , try looking at eventviewer logs by going to Start->Run->Eventvwr
  6. This should be a good way to debug this problem.
  1. 展开 References Item 并检查是否有任何项目附加了警告符号。
  2. 如果 (1) ,单击References->Add Reference并尝试添加有警告的引用。现在警告标志必须消失。
  3. 如果“添加引用”对话框中显示的引用是灰色的,您应该可以通过将鼠标悬停在引用旁边来了解原因。
  4. 对我来说,它是灰色的,它清楚地提到该组件与当前的 .NET Target 运行时不兼容。右键单击Project -> 'Properties'并尝试更改 .NET Runtime,然后编译整个解决方案并尝试执行它。
  5. 如果仍然失败,请尝试通过开始->运行->Eventvwr查看事件查看器日志
  6. 这应该是调试这个问题的好方法。


回答by mofidul

Honestly...I deleted the App.config file and Re-build. And started working.

老实说......我删除了 App.config 文件并重新构建。并开始工作。

回答by R. Schreurs

Without understanding what was going on, I was able to fix this issue for a Windows Forms project I had just converted from VS.Net 2008 to 2010.

在不了解发生了什么的情况下,我能够为刚刚从 VS.Net 2008 转换到 2010 的 Windows 窗体项目解决此问题。

After conversion the Target Frameworkwas still .Net Framework 2. When I changed it to 4.0, my application could be started and debugged. In then noticed a new line in app.config:

转换后目标框架仍然是.Net Framework 2。当我将其更改为 4.0 时,我的应用程序可以启动和调试。然后注意到 app.config 中有一个新行:

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

So, just for the sake of interest, I changed the Target Framework back to 2.0 and the line changed to:

所以,只是为了兴趣,我将目标框架改回 2.0 并将该行更改为:

<startup><supportedRuntime version="v2.0.50727"/></startup>

The application would still run. Then, I removed the new line altogether and the application would still run!

该应用程序仍将运行。然后,我完全删除了新行,应用程序仍然可以运行!

Finally, I undid all my changes and started the conversion again. Now, the application would run immediately!

最后,我撤消了所有更改并再次开始转换。现在,应用程序将立即运行!

So, if you run into this issue, just try these steps and see if it helps you.

因此,如果您遇到此问题,请尝试这些步骤,看看是否对您有所帮助。

回答by t3chb0t

In my case the reason for this error was an invalid app.config. R#renamed the root element from <configuration>to something else (probably because there was another variable that I renamed with the same name).

在我的情况下,此错误的原因是 invalid app.configR#将根元素从 重命名<configuration>为其他内容(可能是因为我用相同的名称重命名了另一个变量)。

I found this by following Gopalakrishnan SA'S advice to look in the Event Viewerwhere I found:

我通过遵循Gopalakrishnan SA的建议来查看Event Viewer我发现的位置,发现了这一点:

Activation context generation failed for "my.exe".Error in manifest or policy file "my.exe.Config" on line 3. The application config file root element must be configuration.

“my.exe”的激活上下文生成失败。清单或策略文件“my.exe.Config”在第 3 行出错。应用程序配置文件根元素必须是配置。

回答by Mehdi Khademloo

In my case, I forgot just a simple note,

就我而言,我忘记了一个简单的笔记,

in the requestedPrivilegesyou should place one requestedExecutionLevel, NOT MORE

requestedPrivileges你应该放置一个requestedExecutionLevel,而不是更多

回答by Tom Andrews

I checked the event viewer to find the error "The application config file root element must be configuration".

我检查了事件查看器以发现错误“应用程序配置文件根元素必须是配置”。

It turns out it was the namespace referenced in the app.config.

原来它是 app.config 中引用的命名空间。

I had opened it in VS 2015 after it being created in VS 2008

在 VS 2008 中创建后,我在 VS 2015 中打开了它