Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 272591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:20:02+00:00 2026-05-12T00:20:02+00:00

I use a WsdlImporter and ServiceContractGenerator to set up CodeDomProvider to get an assembly

  • 0

I use a WsdlImporter and ServiceContractGenerator to set up CodeDomProvider to get an assembly which (I thought) should allow me to create an instance of my HelloWorldService.

MetadataExchangeClient mexClient = new MetadataExchangeClient(metadataAddress);
mexClient.ResolveMetadataReferences = true;
MetadataSet metaDocs = mexClient.GetMetadata();

WsdlImporter importer = new WsdlImporter(metaDocs);
ServiceContractGenerator generator = new ServiceContractGenerator();

System.Collections.ObjectModel.Collection<ContractDescription> contracts
            = importer.ImportAllContracts();
importer.ImportAllEndpoints();
foreach (ContractDescription contract in contracts)
{
    generator.GenerateServiceContractType(contract);
}

if (generator.Errors.Count != 0)
{
    throw new Exception("There were errors during code compilation.");
}

CodeDomProvider codeDomProvider = CodeDomProvider.CreateProvider("C#");

CompilerParameters parameters = new CompilerParameters();
parameters.CompilerOptions = string.Format(@" /lib:{0}", "\"C:\\Program Files\\Reference Assemblies\\Microsoft\\Framework\\v3.0\"");
parameters.ReferencedAssemblies.Add("System.ServiceModel.dll");
parameters.ReferencedAssemblies.Add("System.Runtime.Serialization.dll");

CodeCompileUnit codeUnit = generator.TargetCompileUnit;

CompilerResults results = codeDomProvider.CompileAssemblyFromDom(parameters, codeUnit);

foreach (CompilerError oops in results.Errors)
{
    throw new Exception("Compilation Error Creating Assembly: " + oops.ErrorText);
}
return results.CompiledAssembly;

assembly.GetExportedTypes() and assembly.GetTypes() return five types: IHelloWorldService, IHelloWorldServiceChannel, HelloWorldServiceClient, and the two DataContract request and response types.

I was expecting to be able to use assembly.CreateInstance(“HelloWorldService”); to get an instance of the service to be able to invoke methods on it, but of course this is null.

What am I missing? Any ideas greatly appreciated. Let me know if you need more detail.

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T00:20:02+00:00Added an answer on May 12, 2026 at 12:20 am

    These techniques are used to create client-side classes. When you create an instance of HelloWorldServiceClient, you’ll be creating an instance of the proxy class that can be used to communicate with the service.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Use Case: Admin should be able to create user, and it should not attempt
Use: The user searches for a partial postcode such as 'RG20' which should then
use WWW::Mechanize; my $mech = WWW::Mechanize->new; $mech->get( $url ); say $mech->text; How could I
USE master GO DECLARE @DbName nvarchar(MAX) SET @DbName = N'DataBase' ALTER DATABASE @DbName SET
use pthread_create to create limited number of threads running concurrently Successfully compile and run
Use the static modifier to declare a static member, which belongs to the type
USE Pooja GO ----Create TestTable CREATE TABLE TestTable(RtJobCode VARCHAR(20), RtProfCode smallint,RtTestCode smallint,ProfCode smallint,TestCode smallint)
Use case: we have some project meta-data files which we want tracked, but are
Use OPENXML to get dt element in MSSQL 2005. How can I get xmlns:dt
USE Database GO CREATE PROCEDURE FillTable @Id nvarchar(50), @ColumnNameArray nvarchar(4000), @ColumnValueArray nvarchar(4000) AS INSERT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.