当我尝试在设计时在即时窗口来评估表达,我得到错误:立即窗口中,“表达无法计算......”
The expression cannot be evaluated while in design mode.
如果我编译ASP.NET项目,并尝试以调试模式运行它我得到另一个错误:
The expression cannot be evaluated while in run mode.
为什么我会得到这些错误?过去我使用了立即窗口,即使在设计模式下也能正常工作。
当我尝试在设计时在即时窗口来评估表达,我得到错误:立即窗口中,“表达无法计算......”
The expression cannot be evaluated while in design mode.
如果我编译ASP.NET项目,并尝试以调试模式运行它我得到另一个错误:
The expression cannot be evaluated while in run mode.
为什么我会得到这些错误?过去我使用了立即窗口,即使在设计模式下也能正常工作。
假设您不缺少立即窗口中的>
操作符,如果您试图在多项目解决方案甚至Web项目中设计时评估表达式,可能会出现问题。
根据MSDN:
If you are attempting to evaluate a function in a project that is not the startup project for the solution and you receive an error, try selecting the project in Solution Explorer and attempt the evaluation again.
另外:
You cannot use design time expression evaluation in project types that require starting up an execution environment, including Visual Studio Tools for Office projects, Web projects, Smart Device projects, and SQL projects.
值得一提的是,立即窗口的行为取决于Visual Studio中的版本使用的是各不相同。如果我尝试在Visual Studio 2013 Express for Web中评估像? 2+2
这样的简单表达式,我会收到“在设计模式下无法评估表达式”错误消息;但是,在Visual Studio 2013 Professional中,表达式的计算结果为4
,而不必处于调试模式。
在我的情况下,在启用本机调试后使用Excel Interop时收到此错误。然后在调试模式下我想这:
?xlworkbook.sheets(1).name
过程挂起,我没有收到任何回答,之后,所有其他的事情,例如?2+2
给了我这个错误:
The expression cannot be evaluated while in run mode
为了能够再次使用调试功能,我不得不关闭本机调试。
由于northben pointed out in a comment,如果你想访问的属性在即时窗口,而您的应用程序没有运行,你可能会得到:
The expression cannot be evaluated while in design mode.
因此:
GlobalConfiguration.Configuration
) - 现在,如果该属性存在于该上下文中,则会得到适当的结果。如果它不存在,那么你将得到:
The expression cannot be evaluated while in run mode.
这是为确保您访问在正确的上下文的属性一样简单。
你想评估什么样的表情? – 2011-05-03 09:10:47
我得到任何表达式,即使在2 + 2上 – Tomas 2011-05-03 09:14:57