Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Debugging Can';t通过VisualStudio调试PowerShell_Debugging_Visual Studio 2010_Powershell - Fatal编程技术网

Debugging Can';t通过VisualStudio调试PowerShell

Debugging Can';t通过VisualStudio调试PowerShell,debugging,visual-studio-2010,powershell,Debugging,Visual Studio 2010,Powershell,我正在开发一个二进制PowerShell模块。我已设置模块项目的“调试”选项卡,以启动PowerShell控制台并导入我的模块。如果我按F5,它会按预期的那样执行 我遇到的问题是VisualStudio并没有真正“连接”到该过程。“模块”窗口为空,未命中任何断点。 如果我手动启动PowerShell并连接到进程…轰!我可以调试 F5ing比构建+启动+反复附加要好:| 有什么想法吗 编辑: 我发现,如果启用非托管代码调试,将看到加载的模块。这是有道理的,因为PowerShell.exe是非托管的

我正在开发一个二进制PowerShell模块。我已设置模块项目的“调试”选项卡,以启动PowerShell控制台并导入我的模块。如果我按F5,它会按预期的那样执行

我遇到的问题是VisualStudio并没有真正“连接”到该过程。“模块”窗口为空,未命中任何断点。

如果我手动启动PowerShell并连接到进程…轰!我可以调试

F5ing比构建+启动+反复附加要好:|

有什么想法吗

编辑:


我发现,如果启用非托管代码调试,将看到加载的模块。这是有道理的,因为PowerShell.exe是非托管的。现在的问题是,在“模块”窗口中,我的所有程序集符号状态都是“符号文件中没有本机符号”。进程“powershell.exe”是“本机”而不是“托管(v2.0.50727)”。看起来VS决定以本机方式而不是以托管模式进行调试。有什么办法可以改变这个问题吗?

我很久以前就解决了这个问题,不记得所有的细节,但这个技巧应该会有所帮助,希望如此

创建文件C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe.config:

<?xml version="1.0"?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0.30319"/>
        <supportedRuntime version="v2.0.50727"/>
    </startup>
</configuration>

x64计算机:文件还需要复制到C:\Windows\SysWOW64\WindowsPowerShell\v1.0

注意:您可能希望删除行
,以避免加载.NET 4(另一方面,您可能确实希望这样做,例如,如果PowerShell即将使用.NET 4程序集)

如果在承载PowerShell的应用程序中使用PowerShell,则在应用程序主目录中创建类似的文件
您的_app.exe.config

据我记忆所及,
这一行实际上帮助VS调试器正常工作。

NB:如果您保留此
请记住,您的所有PS控制台会话都是使用.NET 4运行的。