简体   繁体   English

如何从 Visual Studio 2022 运行 WcfTestClient?

[英]How to run WcfTestClient from Visual Studio 2022?

I have installed VS 2022, I need to use the WcfTestClient to test my service.我已经安装了 VS 2022,我需要使用 WcfTestClient 来测试我的服务。 But I cannot find it.但我找不到它。

It used to be in the below location in VS 2019.它曾经位于 VS 2019 中的以下位置。

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE

FYI.供参考。 Even if you install the WCF option, the WcfTestClient that currently ships with VS2022 up to version 17.1.0 is broken.即使您安装了 WCF 选项,当前 VS2022 附带的 WcfTestClient 版本 17.1.0 也已损坏。 The issue is easy to duplicate.这个问题很容易重复。 Simply create a WCF Service Application using the standard template and then run the app with Service1.svc.cs open as the current document.只需使用标准模板创建一个 WCF 服务应用程序,然后运行该应用程序并将 Service1.svc.cs 作为当前文档打开。 It will launch with your service but as soon as you select a method in the left pane and then click on any cell in the right grid, it crashes with the following exception:它将与您的服务一起启动,但是只要您在左窗格中 select 一个方法,然后单击右网格中的任何单元格,它就会崩溃并出现以下异常:

Managed Debugging Assistant 'PInvokeStackImbalance': 'A call to PInvoke function 'Microsoft.VisualStudio.VirtualTreeGrid.托管调试助手“PInvokeStackImbalance”:“调用 PInvoke function”Microsoft.VisualStudio.VirtualTreeGrid。 Microsoft.VisualStudio.VirtualTreeGrid:NativeMethods:.NotifyWinEvent' has unbalanced the stack. Microsoft.VisualStudio.VirtualTreeGrid:NativeMethods:.NotifyWinEvent' 使堆栈不平衡。 This is likely because the managed PInvoke signature does not match the unmanaged target signature.这可能是因为托管 PInvoke 签名与非托管目标签名不匹配。 Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.'检查 PInvoke 签名的调用约定和参数是否与目标非托管签名匹配。

The issue has been reported to Microsoft, but as of right now it appears that they consider it a low priority.该问题已报告给微软,但截至目前,他们似乎认为它的优先级较低。 The workaround we use is to leave VS2019 installed and create a short-cut to the VS2019 version of the WcfTestClient, and then execute the VS2019 version manually to test our services.我们使用的解决方法是保留安装 VS2019 并创建 VS2019 版本的 WcfTestClient 的快捷方式,然后手动执行 VS2019 版本以测试我们的服务。

Two things to check:要检查的两件事:

  1. Do you have the WCF tooling installed?您是否安装了 WCF 工具? Double check this in the VS installer by going to Modify your install and search for it in the Individual Components tab:在 VS 安装程序中仔细检查这一点,方法是修改您的安装并在单个组件选项卡中搜索它: 显示 WCF 工具安装状态
  2. Make sure you're looking in the 64-bit installation path.确保您正在查看 64 位安装路径。 Since VS2022 is 64-bit, it is now installed under c:\Program Files\ (without the (x86) ).由于 VS2022 是 64 位的,它现在安装在c:\Program Files\下(没有(x86) )。
  1. Make sure WCF tooling is installed as suggested by @Jimmy确保按照@Jimmy 的建议安装了 WCF 工具
  2. Make sure IIS is enabled on your Windows machine确保在您的 Windows 机器上启用了 IIS

To enable IIS:启用 IIS:

Go to Control Panel -> Programs Go 到控制面板 -> 程序

Under Programs and Features, click on Turn Windows features on or off在程序和功能下,单击打开或关闭 Windows 功能

Select every checkbox under Inte.net Information Services -> Click Ok Select Inte.net 信息服务下的每个复选框 -> 单击确定

That's all.就这样。

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

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