locked
Problem with multiple services with shared datamember baseclass and svcutil RRS feed

  • Question

  • I have a couple of WCF services (different service contracts) where the data classes when invoking and returning data all has the same base class.
    This leads to problems with svcutil and the generation of code. I want to add the generated proxy classes' to a single project but get multiple errors like this one:

    Error	1	The namespace 'MyNamespacce' already contains a definition for 'MyVar'	File.cs
    ...

    Any ideas on how to solve this? Right now, we have to manually edit all the classes and remove the duplicate base class which is very frustrating and time consuming.

    The data contracts and service contracts has different namespaces but that does not help, the base class and other contracts is in their "old" .net namespace while the service classes has the namespace defined with the /namespace-argument to svcutil.

    Svcutil is used like this: (As a bat-file with multiple lines, one for each service)
    svcutil.exe http://localhost/ServiceName /tcv:Version35 /namespace:WSNamespace,NewNetNamespace /config:My.Config
    svcutil.exe http://localhost/ServiceName2 /tcv:Version35 /namespace:WSNamespace,NewNetNamespace /mergeConfig
    ...
    Any ideas or suggestions on this problem?
    Wednesday, October 7, 2009 2:53 PM

Answers

  • Hi,

    Can you try this.

    svcutil.exe http://localhost/ServiceName /tcv:Version35 /namespace:"*,NewNetNamespace" /config:My.Config
    svcutil.exe http://localhost/ServiceName2 /tcv:Version35 /namespace:"*,NewNetNamespace1" /mergeConfig

    This generates two classes and each of them will be in a different CLR namespace(NewNetNamespace and NewNetNamespace1).
    • Marked as answer by Dhanjel Wednesday, October 7, 2009 3:32 PM
    Wednesday, October 7, 2009 2:59 PM

All replies

  • Hi,

    Can you try this.

    svcutil.exe http://localhost/ServiceName /tcv:Version35 /namespace:"*,NewNetNamespace" /config:My.Config
    svcutil.exe http://localhost/ServiceName2 /tcv:Version35 /namespace:"*,NewNetNamespace1" /mergeConfig

    This generates two classes and each of them will be in a different CLR namespace(NewNetNamespace and NewNetNamespace1).
    • Marked as answer by Dhanjel Wednesday, October 7, 2009 3:32 PM
    Wednesday, October 7, 2009 2:59 PM
  • You're defininately my hero today! Even though it required quite large modifications of our projects and namespaces. 
    But it works and will improve our proxy-generation-time in the future :)
    Wednesday, October 7, 2009 3:31 PM
  • I adore you!!
    Friday, May 7, 2010 9:18 AM
  • ,

    as there any other way to do it without forcing the client to change the namespace? Maybe [MessageContract] attributes like IsWrapped ir WrapperName or WrapperNamespace could help somehow? I tried different approaches with MessageContract attributes with no success so far :(

    Regards,

        Adam

    Tuesday, January 3, 2012 3:34 PM