views:

2281

answers:

5

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)

http://tinyurl.com/6wp2kr http://tinyurl.com/ayb36h http://tinyurl.com/8nqovx

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.

A: 

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.

Philippe
I believe anytime you use CodeDom (see http://msdn.microsoft.com/en-us/library/y2k85ax6.aspx for more information) this comment is automatically included in the generated source file. So this could just mean that both svcutil and Visual Studio 2008 both use CodeDom.
Dan Esparza
Yup, could be CodeDom version. Apparently nobody knows the answer to that question...
Philippe
It is. I have written a custom code generator using CodeDom and the same comments appear in the output, even though I'm 100% sure I didn't add those.
Badaro
A: 

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.

Piotr Owsiak
+1  A: 

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.

Marc Gravell
A: 

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.

John Saunders
A: 

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.

slugster