问题
I'd like to run WcfTestClient (one that's included with VS2012) on a different machine without installing VS2012. Is this possible? On the machine I've installed .NET 4.5 but when I try to add web services it gives me the following stack trace:
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Tools.Common.SdkPathUtility.GetRegistryValue(String registryPath, String registryValueName)
at Microsoft.Tools.Common.SdkPathUtility.GetSdkPath(Version targetFrameworkVersion)
at Microsoft.Tools.TestClient.ToolingEnvironment.get_MetadataTool()
at Microsoft.Tools.TestClient.ServiceAnalyzer.GenerateProxyAndConfig(String projectPath, String address, String configPath, String proxyPath, Int32 startProgressPosition, Int32 endProgressPostition, BackgroundWorker addServiceWorker, String& errorMessage)
at Microsoft.Tools.TestClient.ServiceAnalyzer.AnalyzeService(String address, BackgroundWorker addServiceWorker, Single startProgress, Single progressRange, String& errorMessage)
at Microsoft.Tools.TestClient.Workspace.AddServiceProject(String endpoint, BackgroundWorker addServiceWorker, Single startProgress, Single progressRange, String& error)
at Microsoft.Tools.TestClient.AddServiceExecutor.Execute(AddServiceInputs inputs, Workspace workspace, BackgroundWorker addServiceWorker)
at Microsoft.Tools.TestClient.UI.MainForm.addServiceWorker_DoWork(Object sender, DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
In the WcfTestClient folder I only have 2 files, is there any other files I need to include? WcfTestClient.exe WcfTestClient.exe.config
Both are copied directly from the VS2012 IDE folder.
回答1:
The WCFTestClient must be run on a computer with the SDK installed. Not only does it look in the registry to find the location of the SDK, but it also runs the svcutil from the SDK to generate the proxy classes to connect at runtime.
回答2:
While developing a .Net 4.0 WCF Service on Windows 7 using VS2012 Pro (Update 4) I found I needed to install the Windows 8.0 SDK, not the Windows 7 SDK as one might otherwise assume. (Added this answer to replace my previous comment).
回答3:
A bit late response, but installing the SDK on the target computer is not needed.
You just need to copy some files and ensure the existence of one registry key.
From local installed VS 2015 (v14.0):
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\WcfTestClient.exe
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.VisualStudio.VirtualTreeGrid\v4.0_14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.VirtualTreeGrid.dll
From local installed Windows SDK (v10):
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\SvcUtil.exe
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\SvcConfigEditor*.*
Registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\NETFXSDK\4.6\WinSDK-NetFx40Tools-x86 (just ensure all keys exists, no content needed)
Full explanation here: https://social.msdn.microsoft.com/Forums/vstudio/en-US/c3c7221c-c06f-4364-887a-fb20f22877be/wcf-test-client-problem?prof=required (the last response, author: Jakub Bereżański)
来源:https://stackoverflow.com/questions/15325867/unable-to-add-service-in-wcftestclient-when-copy-to-a-different-machine