none
svcUtil error

    Question

  • I have a Console Application service. I have exposed the endpoints using an App.Config.

    I m trying to generate client config file and proxy file for the use at client end.

    I m using svcutil, but i get the following error:

     

    -service Name - SelfCalcService

    -Exe name - SelfCalcService.exe

    Namespace - SelfCalcService

     

     

    svcutil SelfCalcService.exe /serviceNameTongue TiedelfCalc.SelfCalcService

     

    Microsoft (R) Service Model Metadata Tool
    [Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.30]
    Copyright (c) Microsoft Corporation.  All rights reserved.

    Generating metadata files...
    Warning: Unable to load a service with configName 'SelfCalc.SelfCalcService'. To
     export a service provide both the assembly containing the service type and an e
    xecutable with configuration for this service.
        Details:Either none of the assemblies passed were executables with configura
    tion files or none of the configuration files contained services with the config
     name 'SelfCalc.SelfCalcService'.

    Warning: No metadata files were generated. No service contracts were exported.
     To export a service, use the /serviceName option. To export data contracts, spe
    cify the /dataContractOnly option. This can sometimes occur in certain security
    contexts, such as when the assembly is loaded over a UNC network file share. If
    this is the case, try copying the assembly into a trusted environment and runnin
    g it. 

     

    what am i missing?

    Friday, May 25, 2007 8:54 AM

Answers

  • The most common way is to publish metadata from a running service and use svcutil on the running service, as James suggested.  This is probably how the client was generated for most of the WCF samples that have svcutil-generated clients.  So host the service, publish metadata

    http://msdn2.microsoft.com/en-us/library/aa751951.aspx

    and then hit the running service with svcutil.

    That said, it seems like your svcutil command on the exe is correct, and I am not sure why it is not working.

    Tuesday, May 29, 2007 10:09 PM
  • I think this is due to the <baseAddresses> in the config file in this sample.  svcutil has a known bug that when you run it against a service assembly with a config file that has <baseAddresses>, it will fail in the way you saw.  The workaround is to comment out the <baseAddresses> section before running svcutil.
    Wednesday, June 13, 2007 4:41 PM

All replies

  • Can you copy the app.config to SelfCalcService.exe.config?  The error suggests that the config file is not found.
    Friday, May 25, 2007 9:05 AM
  •  

    Thanks Brian...

    SelfCalcService.exe.config is autogenerated....I need not copy it...

    Secondly, when I checked the contents of it...they are same as the App.config file.

    Any more info u require...I'll be pleased to share.

     

    In few WCF samples... the client code is generated in a similar way...

    but m unsure how hv they done it ??

     

    -Pallz

     

    Friday, May 25, 2007 9:57 AM
  • Maybe I'm not reading the exception correctly, but it says, "Unable to load a service with configName 'SelfCalc.SelfCalcService'."  Doesn't this mean it's looking for a config file named, 'SelfCalc.SelfCalcService.config?' 

    But this isn't the kind of error you should have to be manually fixing.  I would delete the files in bin\Debug and rebuild the project.  Make sure App.config for the service is in the same project as the rest of the service.  Then check the bin\Debug dir again.  It should contain the .exe file and the config file, which has the exact same name as the .exe file, appended with .config.

     

     

    Alternatively, you can also run svcutil against the running service if httpget is enabled (through service metadata behavior).  If it can be run in a console app, just start it up, then run:

     svcutil.exe <serviceAddress>

    I find the easiest way to enable metadata behavior is through config.  I usually just open the App.config file with svcConfigEditor and add the metadata behavior through that.

     

    -James

     

    Friday, May 25, 2007 4:44 PM
    Moderator
  • Can you share the config file?  In particular, I want to see if the <service name=...> has the right name (that you passed as serviceName to svcutil).
    Friday, May 25, 2007 11:20 PM
  • Methinks that the switch with the svcutil command is incorrect.

    The app is console app and the exe name is SelfCalcService.exe

     

    Here are the files for your ref

     

    SERVICE.cs
    namespace SelfCalc
    {
        [ServiceContract()]
        public interface ICalc
        {
     ....
        }
        public class SelfCalcService : ICalc
        {
         ....
        }
    }

     

    CONFIG FILE
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <system.serviceModel>
        <services>
          <service
           name="SelfCalcService"
     ....
     ....

    Monday, May 28, 2007 4:47 AM
  • Try changing <service name="SelfCalc.SelfCalcService"> (that is "namespace.typename").
    Monday, May 28, 2007 4:52 AM
  • Hi,

    Thanks Brian, I shud have updated you on this.

    Tried this option both in the config file and in the Service.cs too.

    I dont see anything wrong in code/config

    Am I using the svcutil command correctly?

     

    I was also going thru the WCF samples for any cue.

    Can you guide me as to how the client side proxy class was generated using the svcutil in the following sample :

    WCF Technology Samples\Extensibility\Security\X509CertificateValidator

     

    Thanx in advance

    -Pallz

    Monday, May 28, 2007 5:49 AM
  • The most common way is to publish metadata from a running service and use svcutil on the running service, as James suggested.  This is probably how the client was generated for most of the WCF samples that have svcutil-generated clients.  So host the service, publish metadata

    http://msdn2.microsoft.com/en-us/library/aa751951.aspx

    and then hit the running service with svcutil.

    That said, it seems like your svcutil command on the exe is correct, and I am not sure why it is not working.

    Tuesday, May 29, 2007 10:09 PM
  • Hi...

    Now consider the following sample...

    \\TechnologySamples\Basic\Service\Hosting\WindowsService

    It is running good....but I wonder how the proxy class was generated ?

     

    svcutil service.exe /servicename:WindowsCalculatorService

     

    I get the following error

    Microsoft (R) Service Model Metadata Tool

    [Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.30]

    Copyright (c) Microsoft Corporation.  All rights reserved.

     

    Generating metadata files...

    Warning: There was an error loading the service type to be exported: Microsoft.S

    erviceModel.Samples.WcfCalculatorService, service, Version=1.0.2720.28990, Cultu

    re=neutral, PublicKeyToken=null.

        Details:This collection already contains an address with scheme http.  There

     can be at most one address per scheme in this collection.

    Parameter name: item

     

    Warning: No metadata files were generated. No service contracts were exported.

     To export a service, use the /serviceName option. To export data contracts, spe

    cify the /dataContractOnly option. This can sometimes occur in certain security

    contexts, such as when the assembly is loaded over a UNC network file share. If

    this is the case, try copying the assembly into a trusted environment and runnin

    g it.

     

    Can this be sorted?

    Wednesday, June 13, 2007 10:53 AM
  • I think this is due to the <baseAddresses> in the config file in this sample.  svcutil has a known bug that when you run it against a service assembly with a config file that has <baseAddresses>, it will fail in the way you saw.  The workaround is to comment out the <baseAddresses> section before running svcutil.
    Wednesday, June 13, 2007 4:41 PM
  • Alright... following can be done...

    For a self-hosted exe, use

    svcutil base-address /out:file_name.cs

     

    svcutil http://localhost:8000/ServiceModelSamples/service /out:myProxy.cs

    This generates the proxy class and config file for client.

    NOTE: The service should be running at the time of proxy creation.

    Tuesday, June 19, 2007 5:04 AM