asp.net-mvc ASP.NET MVC5/IIS Express 无法调试 - 代码未运行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19472682/
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-08 03:13:47  来源:igfitidea点击:

ASP.NET MVC5/IIS Express unable to debug - Code Not Running

asp.net-mvcvisual-studio-debuggingiis-expressvisual-studio-2013asp.net-mvc-5

提问by Graeme

I start a VS2013 VB.Net MVC5 Web Application, set a breakpoint in HomeController About method and run "Start Debugging", navigate to About page and receive the message "Code not running - The current Thread is not currently running or the call stack could not be obtained"preventing any debugging.

我启动了一个 VS2013 VB.Net MVC5 Web 应用程序,在 HomeController About 方法中设置一个断点并运行“Start Debugging”,导航到 About 页面并收到"Code not running - The current Thread is not currently running or the call stack could not be obtained"阻止任何调试的消息。

If I set a breakpoint in Global.asax Application_Start, the breakpoint works fine. Changing the "Enable Edit & Continue" makes no difference.

如果我在 Global.asax Application_Start 中设置断点,断点工作正常。更改“启用编辑并继续”没有任何区别。

Anyone have any ideas what is happening?

任何人都知道发生了什么?

Update: My environment was Windows 8.0 Pro with VS2013 Ultimate.

更新:我的环境是带有 VS2013 Ultimate 的 Windows 8.0 Pro。

I have since flushed my system and done a completely fresh install of Windows 8.1 Pro, VS2010 Ultimate, VS2012 Ultimate, & VS2013 Ultimate.

从那以后,我刷新了我的系统并全新安装了 Windows 8.1 Pro、VS2010 Ultimate、VS2012 Ultimate 和 VS2013 Ultimate。

Same test done on all 3 versions of VS - File > New Project > MVC (Default). All 3 versions of VS are reporting "Process with an Id of xxx is not running."

对 VS 的所有 3 个版本都进行了相同的测试 - 文件 > 新建项目 > MVC(默认)。所有 3 个版本的 VS 都报告“ Process with an Id of xxx is not running.

VS2013 debug trace reports "The program '[7720] iisexpress.exe: Program Trace' has exited with code 0 (0x0). The program '[xxxx] iisexpress.exe' has exited with code -1073741816 (0xc0000008) 'An invalid handle was specified'."

VS2013 调试跟踪报告"The program '[7720] iisexpress.exe: Program Trace' has exited with code 0 (0x0). The program '[xxxx] iisexpress.exe' has exited with code -1073741816 (0xc0000008) 'An invalid handle was specified'.

I have run VS in and out of Administrator mode and receive the same results. I have uninstalled and reinstalled IIS Express 8.0.

我已经在管理员模式下运行 VS 并收到相同的结果。我已经卸载并重新安装了 IIS Express 8.0。

采纳答案by Graeme

The solution to the above problem was a simple one. Close down dev environments, go to Documents folder and rename IISExpress. Now set environment variable _CSRUN_DISABLE_WORKAROUNDS ( ref: http://gauravmantri.com/2013/02/05/workaround-for-iis-express-crashing-when-running-windows-azure-cloud-service-web-role-with-multiple-instances-in-windows-azure-sdk-1-8-compute-emulator/).

上述问题的解决方法很简单。关闭开发环境,转到 Documents 文件夹并重命名 IISExpress。现在设置环境变量 _CSRUN_DISABLE_WORKAROUNDS(参考:http://gauravmantri.com/2013/02/05/workaround-for-iis-express-crashing-when-running-windows-azure-cloud-service-web-role-with-多个实例在windows-azure-sdk-1-8-compute-emulator/)。

Now reboot PC, start VS, load website and run in debug. IIS automatically regenerated the IISExpress folder and the environment variable resolved conflicts.

现在重新启动PC,启动VS,加载网站并在调试中运行。IIS 自动重新生成 IISExpress 文件夹,环境变量解决了冲突。

回答by Deano

For me the solution was a much simpler one. In my Solution Explorer in Visual Studio, I right click on the web project, chose properties and then navigated to the "web" tab. From there I changed the Project URL to another port number. For example, if it was http://localhost:1052- I changed it to http://localhost:4356.

对我来说,解决方案要简单得多。在 Visual Studio 的解决方案资源管理器中,我右键单击 Web 项目,选择属性,然后导航到“Web”选项卡。从那里我将项目 URL 更改为另一个端口号。例如,如果是http://localhost:1052- 我将其更改为http://localhost:4356.

Process with an Id of xxx is not running.

ID 为 xxx 的进程未运行。

Not sure if this helps anyone else, but it worked for me - hopefully it will work for you too!

不确定这对其他人是否有帮助,但它对我有用 - 希望它也对你有用!

回答by Graeme

If you are using 64 bit machine

如果您使用的是 64 位机器

Go to Visual Studio > Tools Menu > Options

转到 Visual Studio > 工具菜单 > 选项

Options window with Projects and Solutions >Web Projects selected and option Use the 64 bit version of IIS Express selected

选择了“项目和解决方案”>“Web 项目”并选择“使用 64 位版本的 IIS Express”选项的“选项”窗口

回答by Vesselin Obreshkov

I had the same problem and my solution was the following:

我遇到了同样的问题,我的解决方案如下:

Instead of deleting the main applicationhost.config(in your "Documents/IIS Express" folder), check your solution folder for a hidden ".vs" folder with a "config" sub-folder. If that folder exists and it has it's own applicationhost.configfile you need to either rename (or delete) that file or edit it and make sure the website(s) configured inside match the ASP.NET web app(s) in your solution that you are trying to debug. Hope this helps.

与其删除主applicationhost.config文件夹(在您的“Documents/IIS Express”文件夹中),不如检查您的解决方案文件夹中是否存在带有“config”子文件夹的隐藏“.vs”文件夹。如果该文件夹存在并且它有自己的applicationhost.config文件,您需要重命名(或删除)该文件或对其进行编辑,并确保其中配置的网站与您的解决方案中的 ASP.NET Web 应用程序相匹配试图调试。希望这可以帮助。

回答by Daniel Vartdal

I had a similar problem while moving from Visual Studio 2013 to Visual Studio 2015 on a MVC project.

在 MVC 项目上从 Visual Studio 2013 移动到 Visual Studio 2015 时,我遇到了类似的问题。

Deleting the whole .vs solution worked as a charm as Johan J v Rensburgpointed out.

正如Johan J v Rensburg指出的那样,删除整个 .vs 解决方案很有魅力。

回答by Ahmed Elbendary

The following steps fix the problem for VS 2015 and VS 2017:

以下步骤修复了 VS 2015 和 VS 2017 的问题:



Close VS.

关闭 VS。

Navigate to the folder of the solution and delete the hidden.vs folder.

导航到解决方案的文件夹并删除隐藏的.vs 文件夹。

open VS.

开VS。

Hit F5 and IIS Express should load as normal, allowing you to debug.

按 F5 和 IIS Express 应该正常加载,允许您进行调试。

回答by Jan Vilimek

Well.. for me it was Telerik JustMock Q3 2013 (13.3.1015.0) that caused the problem. Uninstalled it from VS 2013 and the problem has gone..

嗯..对我来说是 Telerik JustMock Q3 2013 (13.3.1015.0) 导致了这个问题。从 VS 2013 卸载它,问题消失了..

see also ASP.NET-MVC4 Code Not Runningand http://feedback.telerik.com/Project/105/Feedback/Details/63749-unable-to-debug-asp-net-projects-with-q3-2013

另请参阅ASP.NET-MVC4 代码未运行http://feedback.telerik.com/Project/105/Feedback/Details/63749-unable-to-debug-asp-net-projects-with-q3-2013

One lost day and many new white hairs... Curse on you Telerik guys! ;)

失去的一天和许多新的白发......诅咒你们 Telerik 伙计们!;)

回答by Yoky

Another scenario may be that the port that IIS is using for your application is already being used by another running application. Try changing the port and see if it works for you.

另一种情况可能是 IIS 用于您的应用程序的端口已被另一个正在运行的应用程序使用。尝试更改端口,看看它是否适合您。

回答by Ashkan Hovold

I started to get this problem with Asp.Net Core Web Applicationsin Visual Studio 2017. It didn't matter if it was the .Net Core Standardversion with .Net 4.5.2or the Coreversion with 1.1in my case. IISExpress crashed when I started debug.

我开始在Visual Studio 2017 中使用Asp.Net Core Web Applications遇到这个问题。在我的情况下,它是带有.Net 4.5.2.Net Core Standard版本还是带有1.1Core版本并不重要。当我开始调试时 IISExpress 崩溃了。

Tried everything, nothing worked until I went into add/remove programsin Windows 10and I uninstalled .net core 1.0 runtime(I had both 1.0 installed AND 1.1). Once that was uninstalled, I started Visual Studio 2017 and my .Net Core Web applications (both kinds) and they both started working again!

尝试了所有方法,直到我在Windows 10 中添加/删除程序并卸载.net core 1.0 运行时(我安装了 1.0 和 1.1)之前,没有任何效果。卸载后,我启动了 Visual Studio 2017 和我的 .Net Core Web 应用程序(两种),它们都重新开始工作!

回答by インコグニト アレクセイ

Go to project directory .vs/config/ and remove applicationhost.config . Then restart project.

转到项目目录 .vs/config/ 并删除 applicationhost.config 。然后重启项目。