private CodeCompileUnit GenerateCodeFromServiceMapFile(string mapFilePath)
        {
            try
            {
                string           generatedNamespace = GetGeneratedNamespace();
                SvcMapFileLoader loader             = new SvcMapFileLoader(mapFilePath);
                SvcMapFile       mapFile            = loader.LoadMapFile() as SvcMapFile;

                HandleProxyGenerationErrors(mapFile.LoadErrors);

                // We always use C# for the generated proxy
                CodeDomProvider provider = System.CodeDom.Compiler.CodeDomProvider.CreateProvider("c#");

                //Note: with the current implementation of the generator, it does all of its
                //  work in the constructor.  This may change in the future.
                VSWCFServiceContractGenerator generator = VSWCFServiceContractGenerator.GenerateCodeAndConfiguration(
                    mapFile,
                    GetToolConfig(mapFile, mapFilePath),
                    provider,
                    generatedNamespace,
                    null, //targetConfiguration
                    null, //configurationNamespace
                    new ImportExtensionServiceProvider(),
                    new TypeResolver(),
                    FRAMEWORK_VERSION_35,
                    typeof(System.Data.Design.TypedDataSetSchemaImporterExtensionFx35)  //Always we are above framework version 3.5
                    );

                // Determine what "name" to display to users for the service if there are any exceptions
                // If generatedNamespace is empty, then we display the name of the .svcmap file.
                string referenceDisplayName = String.IsNullOrEmpty(generatedNamespace) ?
                                              System.IO.Path.GetFileName(mapFilePath) : generatedNamespace;

                VerifyGeneratedCodeAndHandleErrors(referenceDisplayName, mapFile, generator.TargetCompileUnit, generator.ImportErrors, generator.ProxyGenerationErrors);
#if DEBUG
#if false
                IO.TextWriter        writer  = new IO.StringWriter();
                CodeGeneratorOptions options = new CodeGeneratorOptions();
                options.BlankLinesBetweenMembers = true;
                provider.GenerateCodeFromCompileUnit(generator.TargetCompileUnit, writer, options);
                Debug.WriteLine("Generated proxy code:\r\n" + writer.ToString());
#endif
#endif
                return(generator.TargetCompileUnit);
            }
            catch (Exception ex)
            {
                string errorMessage = ex.Message;
                errorMessage = String.Format(CultureInfo.CurrentCulture, "{0}: {1}", IO.Path.GetFileName(mapFilePath), errorMessage);
                throw new InvalidOperationException(errorMessage, ex);
            }
        }
        private CodeCompileUnit GenerateCodeFromServiceMapFile(string mapFilePath)
        {
            try
            {
                string generatedNamespace = GetGeneratedNamespace();
                SvcMapFileLoader loader = new SvcMapFileLoader(mapFilePath);
                SvcMapFile mapFile = loader.LoadMapFile() as SvcMapFile;

                HandleProxyGenerationErrors(mapFile.LoadErrors);

                // We always use C# for the generated proxy
                CodeDomProvider provider = System.CodeDom.Compiler.CodeDomProvider.CreateProvider("c#");

                //Note: with the current implementation of the generator, it does all of its
                //  work in the constructor.  This may change in the future.
                VSWCFServiceContractGenerator generator = VSWCFServiceContractGenerator.GenerateCodeAndConfiguration(
                    mapFile,
                    GetToolConfig(mapFile, mapFilePath),
                    provider,
                    generatedNamespace,
                    null, //targetConfiguration
                    null, //configurationNamespace
                    new ImportExtensionServiceProvider(),
                    new TypeResolver(),
                    FRAMEWORK_VERSION_35,
                    typeof (System.Data.Design.TypedDataSetSchemaImporterExtensionFx35) //Always we are above framework version 3.5
                );

                // Determine what "name" to display to users for the service if there are any exceptions
                // If generatedNamespace is empty, then we display the name of the .svcmap file.
                string referenceDisplayName = String.IsNullOrEmpty(generatedNamespace) ?
                    System.IO.Path.GetFileName(mapFilePath) : generatedNamespace;
                
                VerifyGeneratedCodeAndHandleErrors(referenceDisplayName, mapFile, generator.TargetCompileUnit, generator.ImportErrors, generator.ProxyGenerationErrors);
#if DEBUG
#if false
                IO.TextWriter writer = new IO.StringWriter();
                CodeGeneratorOptions options = new CodeGeneratorOptions();
                options.BlankLinesBetweenMembers=true;
                provider.GenerateCodeFromCompileUnit(generator.TargetCompileUnit, writer, options);
                Debug.WriteLine("Generated proxy code:\r\n" + writer.ToString());
#endif
#endif
                return generator.TargetCompileUnit;
            }
            catch (Exception ex)
            {
                string errorMessage = ex.Message;
                errorMessage = String.Format(CultureInfo.CurrentCulture, "{0}: {1}", IO.Path.GetFileName(mapFilePath), errorMessage);
                throw new InvalidOperationException(errorMessage, ex);
            }
        }