简体   繁体   English

如何在ASP.Net MVC 6中编辑和继续

[英]How to Edit and Continue in ASP.Net MVC 6

Back in the days using older versions of Visual Studio and ASP.NET was possible to edit the code while you were debugging it (even with some limitations). 在使用旧版本的Visual Studio和ASP.NET的日子里,可以在调试时编辑代码(即使有一些限制)。

How can I enable edit and continue using ASP.Net/VNext (MVC 6) with VS 2015 RC. 如何在VS 2015 RC中启用编辑并继续使用ASP.Net/VNext(MVC 6)。 This feature is available? 这个功能可用吗? The message that I receive is: 我收到的消息是:

错误 "Changes are not allowed if the project wasn't built when debugging started". “如果在调试开始时没有构建项目,则不允许进行更改”。

How can I build the project when the debug mode is starting? 如何在调试模式启动时构建项目?

I got Edit and Continue to work in VS 2015 on my ASP.Net MVC 4 project. 我在我的ASP.Net MVC 4项目中获得编辑并继续在VS 2015中工作。 David R posted a link in his answer (here again for completeness) David R在他的回答中发布了一个链接(这里又是为了完整性)

http://blogs.msdn.com/b/visualstudioalm/archive/2015/04/29/net-enc-support-for-lambdas-and-other-improvements-in-visual-studio-2015.aspx http://blogs.msdn.com/b/visualstudioalm/archive/2015/04/29/net-enc-support-for-lambdas-and-other-improvements-in-visual-studio-2015.aspx

The page says that VS2015 supports Edit Continue on Attach To Process if an environment variable is set during load of the runtime. 页面说如果在加载运行时期间设置了环境变量,VS2015支持在Attach To Process上编辑继续。 The way I understand it is that this variable cues in the CLR to allocate a little bit of extra memory which is needed for Edit and Continue to work. 我理解的方式是这个变量在CLR中提示分配一点额外的内存,这是编辑和继续工作所需要的。

Now the trick is to get the w3wp.exe process running your application pool to load with this variable. 现在的诀窍是让运行应用程序池的w3wp.exe进程加载此变量。 On any other process I would just open a command line and do 在任何其他进程中,我只需打开命令行即可

set COMPLUS_FORCEENC=1
ExeToDebug.exe

But I couldn't find a way to directly run my app pool with an environment variable. 但我找不到用环境变量直接运行我的应用程序池的方法。 I posted a workaround (as CSUdev) on this page, that is a little hack which sets a machine level environment variable, resets iis, calls a url which starts the app pool, then clears the machine level environment variable. 我在这个页面上发布了一个解决方法(作为CSUdev),这是一个设置机器级环境变量的小黑客,重置iis,调用启动应用程序池的URL,然后清除机器级环境变量。 http://forums.iis.net/p/1195182/2115550.aspx?p=True&t=635895941266217500 http://forums.iis.net/p/1195182/2115550.aspx?p=True&t=635895941266217500

The OP in that thread said he used to have this working in prior versions of IIS by setting Environment variables for the user profile that the Application Pool would then load when its user profile loaded, although he wasn't able to get the working in IIS8 (might be related to WS2012/Win8 security settings in the OS). 该线程中的OP表示他曾经在IIS的早期版本中使用此工作,方法是为用户配置文件设置环境变量,然后在加载用户配置文件时加载应用程序池,尽管他无法在IIS8中运行(可能与OS中的WS2012 / Win8安全设置有关)。

tldr; tldr; here's how I got it working 这是我如何运作的

Wrote bat script... 写了蝙蝠脚本......

#set Edit n Continue variable (global... :/ )
setx /m COMPLUS_FORCEENC 1

#kill/restart existing app pools
iisreset

#force app pool to start up (and use the Edit & Continue var)
#you can download wget or curl (instead of start) 
#if you don't want this to open up your default browser every time
start "http://localhost/urlForAspNetApp" 

#clear Edit n Continue var
setx /m COMPLUS_FORCEENC ""

Then VS2015 attach to process w3wp.exe. 然后VS2015附加到进程w3wp.exe。 Bam. 巴姆。 Edit and Continue. 编辑并继续。 Thanks MS & VS2015 folks! 谢谢MS和VS2015大家好评!

Edit and Continue does not work for ASP.NET 5 applications at this point in Visual Studio 2015, but it is planned to support it in the final 2015 release. “编辑并继续”在Visual Studio 2015中此时不适用于ASP.NET 5应用程序,但计划在2015年最终版本中支持它。

For more information about VS2015 ENC changes, have a look at this blog entry: http://blogs.msdn.com/b/visualstudioalm/archive/2015/04/29/net-enc-support-for-lambdas-and-other-improvements-in-visual-studio-2015.aspx 有关VS2015 ENC更改的更多信息,请查看此博客条目: http//blogs.msdn.com/b/visualstudioalm/archive/2015/04/29/net-enc-support-for-lambdas-and-其他-改进-在视觉工作室,2015.aspx

I have ASP.NET MVC5 and realized that if you use IIS Express "Edit and Continue" works pretty much out of the box. 我有ASP.NET MVC5,并意识到,如果你使用IIS Express“编辑并继续”工作几乎开箱即用。

With "Local IIS" it does not work, did not try the "COMPLUS_FORCEENC" setting from matrixugly's post though. 使用“本地IIS”它不起作用,但没有尝试从matrixugly的帖子中的“COMPLUS_FORCEENC”设置。

Ended up switching to IIS Express for debugging because of this. 因此,最终切换到IIS Express进行调试。

在安装此服务更新后,MVC 6项目的VS 2015 Update 1似乎已得到修复https://www.microsoft.com/en-us/download/details.aspx?id=50723

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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