This project is read-only.


When dealing with a large number of service contracts, both the "Add Service Reference..." Visual Studio command and svcutil.exe perform extremely slowly. In some cases an error occurs and no proxies are generated.
At the cost of losing some generality, a template-based approach code generation can provide good enough results for most needs.
This add-in takes a project containing the service contracts and generates both asynchronous and synchronous proxies to be used in client applications. Data contract classes are supposed to be shared between the service and its clients.

For users

The supplied installer will copy the necessary files to the Visual Studio Addin folder under your Documents folder. Any existing .config file will be preserved.
The first time you use the addin, you must need to define at least one configuration to use with your solution. To invoke the addin, use the menu option Tools | WCF Client Generator.
Addin-menu That will show the main window for the addin.
Just press the Configure… button and define the values that suit your code generation needs.
The first time you need to press the Add button and give values to the configuration fields:
  • Name: Choose a name that identifies the configuration.
  • Contracts: Select the project that contains your service contracts. This project must compile without errors before using the generate code action.
  • Sync Proxies: Select the project that will use the generated synchronous proxies files. It’s not mandatory, but you must define a sync proxies destination project or an async proxies destination project or both. You can select more than one destination project.
  • Async Proxies: Select the project that will use the generated asynchronous proxies files. It’s not mandatory, but you must define a sync proxies destination project or an async proxies destination project or both. You can select more than one destination project.
  • Templates: Select the assembly containing the templates to use for generating the proxies code. The addin setup contains a default implementation but you can supply your custom implementation.
  • Client Base: The name of the base class for the proxy client class.
  • Namespace: The XML namespace of your web service.
  • Usings: An optional usings list to include in the generated proxy files.
  • Temp Folder (advanced): The folder where the temporary files will be generated.
  • Image (advanced): An optional PNG image to show in the configurations list. Images with transparent backgrounds are preferred.
  • Background (advanced): A color to display as the background of the configuration image.

For developers

The Addin project follows the common structure having a link to a "- For testing.Addin" file deployed to the Visual Studio Addin folder. When you open the solution for the first time you'll be missing this link. I've provided it under the "_To addin folder" solution folder. Before debugging you must:
  • Change the <Assembly> element to suit your development solution folder
  • In the WcfClientGenerator project properties Debug tab:
    • Select Start external program and provide the path to your Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.
    • Provide the following Command line arguments: /resetaddin WcfClientGenerator.WcfClientGeneratorAddIn
    • Set your Microsoft Visual Studio 10.0\Common7\IDE\ folder as Working directory

The proxy generation process inspects the service contracts in the configured contracts project and uses preprocessed T4 text templates to generate the proxies code. You can supply your own templates assembly by implementing the following interface:

    /// <summary>
    /// The interface all text template-based generators must satisfy
    /// </summary>
    public interface ITemplateGenerator
        #region Events

        /// <summary>
        /// Signals the completion of a step during the generation process
        /// </summary>
        event EventHandler<ProgressEventArgs> ProgressChanged;
        /// <summary>
        /// Signals the completion of the generation process
        /// </summary>
        event EventHandler<GenerationResultEventArgs> ProcessFinished;


        #region Properties
        /// <summary>
        /// The configuration parameters needed during the generation process
        /// </summary>
        string Configuration { set; }
        /// <summary>
        /// The interfaces needed during the generation process
        /// </summary>
        IEnumerable<Namespace> Namespaces { set; }
        /// <summary>
        /// The number of steps needed to complete the process
        /// </summary>
        int StepCount { get; }


        #region Methods

        /// <summary>
        /// Starts the generation process asynchronously
        /// </summary>
        void GenerateAsync();
        /// <summary>
        /// Cancels the generation process
        /// </summary>
        void Cancel();

The addin will supply the configuration xml as a string in the Configuration property and the contracts project inspection results in the Namespaces property. Then it will invoke the GenerateAsync method on your implementation.

Your responsibilities will be:

  • Returning the number of steps needed for completing the generation process (StepCount property).
  • Fire the ProgressChanged event at each progress step.
  • Fire the ProcessFinished event when the generation is finished.

Last edited Sep 22, 2011 at 9:28 AM by joseluisb_raona, version 11


ramosrf Jul 20, 2010 at 2:02 PM 
Very well this version thanks

cap_huevo May 22, 2010 at 2:36 PM 
Great Add-in!!