简体   繁体   English

Visual Studio 2013 C#交互式窗口

[英]Visual Studio 2013 C# Interactive Window

是否有VS 2013的C#交互式窗口,或任何其他类似的方式,没有安装VS 2012.我尝试了C#Repel,C#Snippet Compiler和Mono Command Prompt,但是,它们都没有提供C#交互式窗口的功能Roslyn for VS 2012。

UPDATE: Found a total better alternative!!! 更新:找到一个更好的选择! Try CShell , it is free and open source! 试试CShell ,它是免费的开源! "A simple, yet powerful, C# scripting IDE" as they promote it. “一个简单而强大的C#脚本IDE”,因为它们会促进它。 Check my tweet which was also favorited by Scott Hanselman :) 查看我的推文 ,这也是Scott Hanselman的收藏:)

My old recommendation was: LINQPad 我的旧推荐是: LINQPad

Best way is to install VS 2012 and use C# interactive window provided with its Roslyn. 最好的方法是安装VS 2012并使用随其Roslyn提供的C#交互式窗口。 While doing that, wait Microsoft to release C# interactive to VS 2013. 在此过程中,请等待Microsoft向VS 2013发布C#interactive。

This is taken from one of the links above: http://social.msdn.microsoft.com/forums/vstudio/en-US/0da45fe7-fbe2-4074-b52f-dc8d7c4b2ba3/c-interactive-in-vs-2013 这取自以上链接之一: http//social.msdn.microsoft.com/forums/vstudio/en-US/0da45fe7-fbe2-4074-b52f-dc8d7c4b2ba3/c-interactive-in-vs-2013

It worked for me, so hopefully this will help the next person :) 它对我有用,所以希望这将有助于下一个人:)

Hi SpencerGR, 嗨SpencerGR,

I just got upgraded to VS 2013 and wanted C# Interactive, and this is the first hit when I searched for it, so I figured I would place my answer here... 我刚刚升级到VS 2013并想要C#Interactive,这是我搜索它时的第一个打击,所以我想我会把答案放在这里......

Didn't make sense to me that the extension from VS 2012 wouldn't work; 对我来说没有意义,VS 2012的扩展不起作用; so I hunted down the Roslyn keys in my registry for VS 2012 and was able to kinda figure out what was going on. 所以我在我的VS 2012注册表中搜索了Roslyn键,并且能够弄清楚发生了什么。 After a bit of futzing around, I finally got it working, so here's the instructions for whoever might care to try [be warned, I'm sure this isn't supported by MS, I take no responsibility if something happens to mess up your computer, and so forth ;)]. 经过一段时间的讨论,我终于得到了它的工作,所以这里有关于任何可能关心尝试的人的指示[被警告,我确信MS不支持这一点,如果发生什么事情搞乱你我不负任何责任电脑,等等;)]。

Basically it was a matter of 基本上它是一个问题

copying some registry keys with slight modification copying some files and this one is annoying but oh, well] there's a file you have to change the datestamp on (I did it by opening the file in Notepad++ and saving it out.) If you don't already have VS 2012 or you don't have the Roslyn CTP installed you'll need to get the files somehow, and I'm not sure if there are other registry settings needed or not, but I imagine if you just manage to get the files out of the CTP distro it would be enough... No guarantees of course. 复制一些注册表项,稍微修改一些文件复制这个文件就很烦人但是哦,好吧,你需要更改日期戳的文件(我是通过在Notepad ++中打开文件然后保存它来完成的。)如果你不这样做已经有了VS 2012,或者你没有安装Roslyn CTP,你需要以某种方式获取文件,我不确定是否需要其他注册表设置,但我想如果你只是设法获得CTP发行版中的文件就够了......当然不能保证。


Not-Instructions-Just-An-Explanation-Of-What-I-Did-I-Am-A-Trained-Professional-...-Or-Something ;) 不是说明 - 只是 - 解释我做了什么我是一个受过训练的专业-...-或者某事;)

  1. copying some registry keys with slight modification; 复制一些注册表项,稍作修改; I replaced '11.0' with '12.0' in the keys and values, you might need to change the paths too if you didn't install Visual Studio in it's default location. 我在键和值中将'11 .0'替换为'12 .0',如果您没有在其默认位置安装Visual Studio,则可能还需要更改路径。 (also posted to pastebin.com/XeP5ai8F ) (也发布到pastebin.com/XeP5ai8F)

Save this as a .reg file and open it to import the new keys easily: 将其另存为.reg文件并将其打开以轻松导入新密钥:

Windows Registry Editor Version 5.00.

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\InteractiveWindows\0] "ContentType"="Roslyn C#"

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config\InstalledProducts\Roslyn] ""="Microsoft Roslyn CTP" "ProductDetails"="Microsoft Roslyn CTP"

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config\Packages\{c5edd1ee-c43b-4360-9ce4-6b993ca12897}] "Class"="Roslyn.VisualStudio.CSharp.Repl.CSharpReplPackage" "CodeBase"="C:\\Program Files (x86)\\Microsoft Visual Studio
12.0\\Common7\\IDE\\Extensions\\Microsoft\\Roslyn C# Interactive Window\\1.2.20906.1\\Roslyn.VisualStudio.CSharp.Repl.dll"

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config\Packages\{f5199a4e-6a60-4f79-82e9-fc92a41c4610}] "Class"="Roslyn.VisualStudio.InteractiveWindow.InteractiveWindowPackage" "CodeBase"="C:\\Program Files (x86)\\Microsoft Visual Studio
12.0\\Common7\\IDE\\Extensions\\Microsoft\\Roslyn Components\\1.2.20906.1\\Roslyn.VisualStudio.InteractiveWindow.dll"

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config\ToolWindows\{2d0a56aa-9527-4b78-b6e6-ebe6e05da749}] "Name"="Roslyn.VisualStudio.InteractiveWindow.VsInteractiveWindow"
  1. copying some files; 复制一些文件; basically just need to copy the files mentioned above to the locations mentioned above; 基本上只需将上述文件复制到上述位置; I just copied the 'Common7\\IDE\\Extensions\\Microsoft\\Roslyn C# Interactive Window' and 'Common7\\IDE\\Extensions\\Microsoft\\Roslyn Components' folders from my 11.0 install to my 12.0 install. 我刚刚将11.0安装中的'Common7 \\ IDE \\ Extensions \\ Microsoft \\ Roslyn C#Interactive Window'和'Common7 \\ IDE \\ Extensions \\ Microsoft \\ Roslyn Components'文件夹复制到我的12.0安装中。 easy peasy. 十分简单。

  2. and yeah... there's a file in the aforementioned 'Common7\\IDE\\Extensions' directory called 'extensions.configurationchanged'; 是的...前面提到的'Common7 \\ IDE \\ Extensions'目录中有一个名为'extensions.configurationchanged'的文件; I couldn't get things to take, then I noticed that file. 我无法接受,然后我注意到了这个文件。 so, as mentioned, I just opened in Notepad++ and saved back out; 所以,如上所述,我刚刚在Notepad ++中打开并保存回来; I think I had to make a change to the file, so I added a space. 我想我必须对文件进行更改,所以我添加了一个空格。 kinda felt kludgy, but I guess it beats VS taking longer to load due to having to scan the Extensions every time you open it up. 有点感觉kludgy,但我想由于每次打开它时必须扫描扩展,它需要更长时间才能加载。


So, that's it! 就是这样了! Worked for me, I hope someone else may find this useful, as it probably took longer to post this than it did to actually get it working in the first place. 为我工作,我希望其他人可能会觉得这很有用,因为它可能需要更长的时间来发布它,而不是实际上让它在第一时间工作。 ;) It's possible I missed a step in here somewhere, since I had made a few other attempts before I found the 'changed' file, so I could have possibly twiddled another bit somewhere that was necessary that I don't remember. ;)我可能错过了这里的一个步骤,因为在我找到'已更改'文件之前我已经做了一些其他的尝试,所以我可能可能在另一个地方错过了一些我不记得的地方。 Should be a good start tho. 应该是一个好的开始。

I haven't tested it out fully by any means but it shows up in the 'View > Other Windows' list, it opens up just find, and it looks like Intellisense is working too. 我没有通过任何方式完全测试它,但它显示在“查看>其他Windows”列表中,它打开刚刚查找,看起来Intellisense也在工作。 Good luck and great code to all! 祝大家好运! :) :)

--- Chelle L. --- Chelle L.

You could also use LinqPad . 你也可以使用LinqPad You can use it to test C# code. 您可以使用它来测试C#代码。 It has built in support for loading DLLs and Nuget Packages. 它内置了对加载DLL和Nuget包的支持。 Its what I use personally and I love it. 它是我个人使用的,我喜欢它。

It has a free version, but the paid version has intellisense and debugger 它有一个免费版本,但付费版本有intellisense和调试器

C# interactive finally arrived to VS 2015... You may need to install vs2015.1 to get it.. C#interactive终于到了VS 2015 ......您可能需要安装vs2015.1来获取它...

http://blogs.msdn.com/b/visualstudio/archive/2015/10/08/visual-studio-2015-update-1-ctp.aspx http://blogs.msdn.com/b/visualstudio/archive/2015/10/08/visual-studio-2015-update-1-ctp.aspx

Good luck... and happy interactive coding! 祝你好运......快乐的互动编码!

IWIH describes how to install it and which prerequisites you need. IWIH描述了如何安装它以及您需要哪些先决条件。

Let me give you some 我给你一些

Additional information: 附加信息:

After you have installed VS 2015 and its updates (update 3 KB3165756 patch has just arrived) you can bring C# interactive to your screen as follows: 安装VS 2015及其更新(更新3 KB3165756补丁刚刚到达)后,您可以将C#interactive带到您的屏幕,如下所示:

Either via the menu 通过菜单

View -> Other Windows -> C# Interactive 查看 - >其他Windows - > C#Interactive

Or press Ctrl + Q and type into the quick launch box: 或按Ctrl + Q并键入快速启动框:

C# interactive C#互动

which allows you to click on View -> Other Windows -> C# Interactive with the mouse. 它允许您使用鼠标单击View -> Other Windows -> C# Interactive

Afterwards, you have the C# Interactive beneath the error list. 之后,您在错误列表下方有C# Interactive Here is an example how you can use it: 以下是如何使用它的示例:

在此输入图像描述

Quickstart: 快速开始:

  • To get help in this window, type #help and press enter. 要在此窗口中获取帮助,请键入#help并按Enter键。
  • To execute a statement, simply press ENTER . 要执行语句,只需按ENTER To type in multiple lines, press SHIFT+ENTER for each line, and for the last line press ENTER to execute the entire statement. 要键入多行,请为每行按SHIFT+ENTER ,对于最后一行,按ENTER执行整个语句。
  • To print the values of a variable, type its name and press enter (in the screen shot, I have done this for variable q ) 要打印变量的值,请键入其名称并按Enter键(在屏幕截图中,我已为变量q

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

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