LINQPad在Visual Studio [英] LINQPad in Visual Studio

查看:324
本文介绍了LINQPad在Visual Studio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 公共静态类扩展{
公共静态无效的转储< T>(这件T O){}
公共静态无效的转储< T>(这件TØ ,字符串s){}}

这行让我的代码形式LINQPad复制到VS并运行它没有注释掉与使用.dump()每行,但还不够...
http://code.google。 COM / p / linqpadvisualizer / - 不是很舒服:(



最好的结果我得到了VS寻找LINQPad是这样的site 与下面的代码由Pat Kujawa

 使用System.Diagnostics程序; 
:使用System.IO;
公共静态类扩展
{
公共静态无效的转储< T>(这件T O)
{
串localUrl = Path.GetTempFileName()+。html的;
使用(VAR作家= LINQPad.Util.CreateXhtmlWriter(真))
{
writer.Write(O);
File.WriteAllText(localUrl,writer.ToString());
}
的Process.Start(localUrl);
}
}



但错误1不存在名称'LINQPad在目前情况下



我无法在网络上找到


解决方案<任何LINQPad.dll / DIV>

这不是为LINQPad需要引用,但LINQPad.exe本身的DLL。



右键单击您的项目在Visual Studio中 - >添加引用 - >浏览通常在其安装目录ç找到EXE二进制文件的位置: \Program Files\LINQPad\ - >选 LINQPad.exe



一旦这样做,那么你就可以在你的文件中添加使用指令吧:

 使用System.Diagnostics程序; 
:使用System.IO;
使用LINQPad;



该方法 LINQPad.Util.CreateXhtmlWriter 将现在可供你使用。


public static class Extensions{
public static void Dump<T>(this T o) { }
public static void Dump<T>(this T o, string s) { }}

These lines allow me to copy code form LINQPad to VS and run it without commenting out every line with .Dump() but it's not enough... http://code.google.com/p/linqpadvisualizer/ - not very comfortable :(

The best result i get searching for LINQPad in VS is this site with code below by Pat Kujawa.

using System.Diagnostics;
using System.IO;
public static class Extensions
{
public static void Dump<T>(this T o)
{
    string localUrl = Path.GetTempFileName() + ".html";
    using (var writer = LINQPad.Util.CreateXhtmlWriter(true))
    {
        writer.Write(o);
        File.WriteAllText(localUrl, writer.ToString());
    }
    Process.Start(localUrl);
}
}

but Error 1 The name 'LINQPad' does not exist in the current context

I couldn't find any LINQPad.dll on the net

解决方案

It's not a dll for LINQPad you need to reference but the LINQPad.exe itself.

Right-click your project in Visual Studio -> Add Reference -> Browse to the exe binary file location typically found in its install directory C:\Program Files\LINQPad\ -> select LINQPad.exe.

Once done, then you can add a "using directive" for it in your file:

using System.Diagnostics;
using System.IO;
using LINQPad;

The method LINQPad.Util.CreateXhtmlWriter will now be available for you to use.

这篇关于LINQPad在Visual Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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