WCF common types not reused

前端 未结 7 1358
梦如初夏
梦如初夏 2020-12-09 04:53

Hint: This questions has many duplicates, but none of the solutions works for me.

What I have is a web service and a client, both having references to a shared assem

相关标签:
7条回答
  • 2020-12-09 05:22

    Referencing the shared assembly before adding the service reference does not work

    You would need to do this, or at least update the service reference after adding the reference.

    Deleting and re-adding the service reference (or the shared assembly reference) did not help

    and you shouldn't need to do this, but I would've tried it too.

    In order for the 'reuse' to work both projects (client and service) need to be using the same version of the assembly. You're referencing the project, which is good - I've encountered this before when referencing the assembly directly because of different versions.

    Here's some other things to try

    • 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. See Simpler Explanation of How to Make Call WCF Service without Adding Service Ref and VS2010 Advantages of Add Service Reference over direct ClientBase<>. This is my preferred WCF pattern because it removes the need to 'Update service reference...', and removes all that generated proxy code.

    0 讨论(0)
提交回复
热议问题