简体   繁体   English

使用PowerShell将VS2010附加到IE9以调试JavaScript

[英]Attach VS2010 to IE9 with PowerShell to debug javascript

Problem (from nuget PowerShell): 问题(来自nuget PowerShell):

  • launch IIS Express (website is in a folder) [done] 启动IIS Express(网站位于文件夹中)[完成]
  • launch IE9 to the URL [done] 将IE9启动到URL [完成]
  • attach current VisualStudio instance to IIS to debug .net code [done] 将当前的VisualStudio实例附加到IIS以调试.net代码[完成]
  • attach current VisualStudio instance to IE9 to debug Javascript code [PROBLEM] 将当前的VisualStudio实例附加到IE9以调试Javascript代码[问题]

Status: 状态:

Currently I'm able from powershell (with $DTE object) to attach VS to IIS and IE9 tab process. 目前,我可以从Powershell(带有$ DTE对象)将VS附加到IIS和IE9选项卡进程。 However I'm not able to debug javascript code (I think VS by default debugs only .net code and not Script). 但是我无法调试javascript代码(我认为VS默认情况下仅调试.net代码而不调试Script)。

I saw EnvDTE80.Transport, but I don't know how to use it inside nuget PowerShell. 我看到了EnvDTE80.Transport,但是我不知道如何在nuget PowerShell中使用它。 Do you have any idea to debug js? 您有调试js的想法吗? Or a completely different approach to the problem? 还是采用完全不同的方法来解决问题?

Update (8 August): I'm able to attach to IE9 debugging js BUT I found that my problem is completely different: 更新(8月8日):我能够附加到IE9调试js,但是我发现我的问题完全不同:

  • I run IIS Express with powershell 我使用Powershell运行IIS Express
  • I run IE9 with powershell 我使用Powershell运行IE9
  • I can get the "Process"es object 我可以得到“过程”对象

BUT I attach the debugger to the processes too early and debugging doesn't work. 但是我太早将调试器附加到进程上了,调试不起作用。

  • I tried (ie) to start IIS Express, start IE9, attach first to IIS and then to IE9. 我尝试启动IIS Express,启动IE9,先附加到IIS,然后再附加到IE9。 Now I'm able to debug script but not to IIS Express. 现在,我可以调试脚本,但不能调试IIS Express。
  • I tried to stop the script 5 second (Start-Sleep -s 5) before attach DTE to processes and now I'm able to debug both IE js and IIS. 在将DTE附加到进程之前,我试图停止脚本5秒钟(Start-Sleep -s 5),现在我可以调试IE js和IIS。 But I don't like sleep solution (how many seconds?). 但是我不喜欢睡眠解决方案(多少秒?)。

I haven't done this via the VS object model but via the GUI, when you attach to a running process like IE9, you can select which debugger type you want. 我尚未通过VS对象模型完成此操作,而是通过GUI完成了此操作,当您连接到IE9等正在运行的进程时,可以选择所需的调试器类型。 In this case, you want the "Script" debugger. 在这种情况下,您需要“脚本”调试器。 If this can be done by the GUI then I suspect that it can be done via the object model. 如果这可以通过GUI完成,那么我怀疑可以通过对象模型完成。 The macro recorder in VS is good for figuring stuff like this out. VS中的宏记录器非常适合解决此类问题。 I turned it on while I did the steps to attach via the GUI and got this: 在执行通过GUI进行附加的步骤时,我将其打开并得到以下信息:

Sub TemporaryMacro()
    Try
        Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
        Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
        Dim dbgeng(1) As EnvDTE80.Engine
        dbgeng(0) = trans.Engines.Item("Script")
        Dim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, "HILLR1").Item("iexplore.exe")
        proc2.Attach2(dbgeng)
    Catch ex As System.Exception
        MsgBox(ex.Message)
    End Try

End Sub

I use firebug to debug Javascript in Firefox. 我使用Firebug在Firefox中调试Javascript。 Chrome has its equivalent. Chrome具有与其等效的功能。 Never tried in IE, but I think there is a Firebug version for IE. 从未尝试在IE中使用,但我认为IE有Firebug版本。

Check this question: Firebug equivalent for Internet Explorer 请检查以下问题: 相当于Internet Explorer的Firebug

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

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