none
WCF service does not reuse common types RRS feed

  • Question

  • I have a Model project which has my classes to be used across the solution. I use the same model as reference in my WCF service as well as the client project for the service. I have checked "Reuse types in specified referenced assemblies" & selected the model class underneath.

    In spite of that, if I do "Update Service Reference" on my service reference in the client project, the service reference generates separate instances of the same classes under the client project. And then I get a lot of ambiguous reference errors in my client project.

    I'm working on VS 2012 Premium & this is the first time I'm working on WCF. I have gone through a lot of posts & tried a lot of options. Nothing worked out. Please let me know what could be wrong.

    Regards,                                                                                                                                                                                       Sitesh


    Thanks & Regards, Sitesh

    Wednesday, September 25, 2013 2:44 AM

Answers

  • Hi,

    When occur this error: WCF service does not reuse common types, please try to refer to the following:

    • Open 'Configuration Manager' for your solution - make sure that the shared assembly is configured to build.
    • Ensure you're using a project reference for both client and service - using the latest assembly on the client won't help if the service is using an older version.
    • Delete the project reference and build, and expect the build to fail - if it doesn't fail then you must be referencing something else.
    • Manually check that the latest 'shared assembly' is being included in the build in both service and client - check the bin folder, check the assembly version / build date.

    If all else fails, the best way to force the same object on both sides is to remove the 'service reference' proxy altogether and use the ChannelFactory method. Please see Simpler Explanation of How to Make Call WCF Service without Adding Service Ref and VS2010 Advantages of Add Service Reference over direct ClientBase<>.

    #Channel Factory in WCF:
    http://www.c-sharpcorner.com/uploadfile/ff2f08/channel-factory-in-wcf/ .

    Best Regards,
    Amy Peng


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.



    Wednesday, September 25, 2013 7:47 AM
    Moderator