Does Visual Studio 2008 Use SvcUtil.exe and if “No” is there any disadvantage to using svcutil?

佐手、 提交于 2019-12-29 07:09:47

问题


After googling a bit there is no definite answer of whether Visual Studio 2008 uses svcutil.exe or not? Visual Studio 2005 did use it, but do the RTM versions of Visual Studio 2008 use svcutil? A few blogs say it doesn't (and make it seem surprising)

  • SVCUtil & VS2008
  • Equivalent svcutil.exe command for VS2008 Add Service Reference
  • SVCUtil Generating WCF client and the is field specified issue

and other sites say it does.

The reason I'm asking is we are flattening our WCF wsdl with a custom endpoint behavior extension (an implementation of IWsdlExportExtension/IEndpointBehavior) and using the flattened wsdl via Visual Studio 2008's Add Reference gives us compile errors as it is duplicating Types/Classes. The reference is added without any errors. SvcUtil, on the other hand, throws the duplicate class into a seperate namespace which fixes the build issue.

So SvcUtil works, but Visual Studio 2008 doesn't on some of our flatten wsdls. We are fine with continueing to use svcutil if the Add Service Reference in Visual Studio doesn't work, but are wondering if anyone knows if there are any implications in doing so. I couldn't find any evidence that we "shouldn't" be using svcutil, just that it isn't as easy as using the Add Service Reference in Visual Studio 2008.


回答1:


svcutil and VS2008 ultimately call into the same bit of WCF code. Whether it uses the actual exe or calls into a dll is a minor detail. If anything, I prefer the command line tool, as it allows more flexibility (or maybe I just like command line ;-p).

Note that WCF can re-use existing types, both via the IDE and from the command-line (/r?). But this type of namespace issue is just one of many things I prefer about using the command-line version.




回答2:


I've never seen any reason to believe that Visual Studio calls svcutil.exe, or wsdl.exe. In both cases, the console applications and Visual Studio use the same .NET Framework code to do their work.

Consider that some errors that occur during an "Add Service Reference" command show up in the Visual Studio "Errors" window, and not in the Output window. It is necessary to call a Visual Studio API to put messages in the Errors window, which svcutil.exe could not do.




回答3:


This is an old question and it came up when i was searching for something similar, so i'll mention what i found.

This blog post asserts that VS2008 doesn't use svcutil to generate proxies. I agree with him, as svcutil doesn't appear in the taskmanager processes list when you add a service reference. They also produce markedly different output - for instance svcutil doesn't produce proxies that are ready for consumption in a Silverlight app, you have to trim a reasonable amount of stuff out of them (like interfaces or object references that are not available in the assemblies that silverlight can use*).

Still, it isn't hard to write a little app that calls svcutil to do the hard work and then do a clean up on the generated files.

*it may be possible to avoid this issue by specifying a different framework version with the /targetClientVersion switch but i haven't tried that yet.




回答4:


I would rather say Visual Studio 2008 is not using svcutil.exe. Well, at least not directly.

I've used Process Monitor to see what applications are executed on my machine while adding a new service reference to my project and could not find "svcutil" in the log.




回答5:


I would say that Visual Studio 2008 does use svcutil to generate proxy code.

As a proof, simply use Visual Studio to generate proxy code, and open the Reference.cs (assuming it was generated in C#) file, you will this header in the file:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.3053
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

Now, use svcutil command line to generate the proxy code. Open the generated file, and you will see the exact same header.

Beside, when you look at the available options in Visual Studio 2008 when you add a service reference, each option correspond to a svcutil argument.



来源:https://stackoverflow.com/questions/408217/does-visual-studio-2008-use-svcutil-exe-and-if-no-is-there-any-disadvantage-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!