Visual Studio 2012中有没有办法在调试时使用F#REPL? [英] Is there a way in Visual Studio 2012 to use F# REPL when debugging c#

查看:160
本文介绍了Visual Studio 2012中有没有办法在调试时使用F#REPL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在c#程序中有一个断点,我很想使用F#REPL来检查我的
代码。你可以使用F#REPL来调试一个C#项目,我可以这样做吗?

If I have a breakpoint in a c# program I would love to use the F# REPL to inspect my code. Is this possible in any way?

推荐答案

当调试F#库项目时,但是C#应用程序/库也会工作(我想)。

You should be able to debug a C# project with the F# REPL -- I do it when debugging F# library projects, but C# applications/libraries will work too (I think).

编译你的C#项目。在F#交互中,使用 #r 指令引用C#程序集(请参阅ArthurFSharp的文章)。在C#代码中插入一个断点。

Compile your C# project. In F# interactive, reference the C# assembly using the #r directive (see ArthurFSharp's post). Insert a breakpoint somewhere in your C# code.

在Visual Studio中,转到工具 - > 附加到进程。在进程列表中查找 Fsi.exe 并双击它;如果您没有看到它,请确保Fsi进程已经启动(只需在F#Interactive窗口中单击即可)。

In Visual Studio, go to Tools -> Attach to Process. Find Fsi.exe in the list of processes and double-click it; if you don't see it there, make sure the Fsi process has been started (just clicking inside the F# Interactive window should do it).

在F#Interactive中,执行一些代码将达到您设置的断点;调试器应该像你想要的那样在断点上停止执行。只要调试器在某个断点上没有停止,您还可以从FSI中执行其他代码,例如更改正在运行的C#应用​​程序中的设置。

In F# Interactive, execute some bit of code that'll reach the breakpoint you set; the debugger should stop execution on the breakpoint just like you want. As long as the debugger isn't stopped on some breakpoint, you can also execute other code from within FSI, for example to change settings in the running C# application.

重要信息:请记住,Windows会在程序集加载到进程中时锁定程序集。这意味着只要FSI打开,您将无法重新编译C#应用程序!该修复很简单,但是一旦您对C#应用程序进行了一些更改,并希望重新编译并重新开始测试,只需右键单击F#Interactive窗口,然后单击上下文菜单中的重置交互式会话。该进程将被杀死并重新启动,所以您可以重新开始。 (如果您忘记重新启动FSI进程并尝试重新编译应用程序,编译将需要比正常程序更长的时间,那么您将收到一条错误消息,告诉您编译器无法写入输出文件。)

IMPORTANT : Remember that Windows locks an assembly whenever it is loaded into a process. This means that you won't be able to recompile your C# app as long as FSI is open! The fix is simple though -- once you've made some changes to your C# app and want to recompile and begin testing again, just right-click within the F# Interactive window and click 'Reset Interactive Session' in the context-menu. The process will be killed and restarted, so you can begin all over again. (If you do forget to restart the FSI process and try to recompile your application, compilation will take a bit longer than normal, then you'll get an error message telling you the compiler couldn't write to the output file.)

这篇关于Visual Studio 2012中有没有办法在调试时使用F#REPL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆