2

I am trying to share classes between my server and client by using a common dll. The client and server communicate via WCF services. When I add/configure the service reference via visual studio the types are not being picked up from the dll. Instead new auto-generated copies are being created and used in the service reference. I have the reuse types un specified referenced assemblies checked and I have my dll checked. If I create the service reference via the svcutil and reference the dll from the bin folder from my client the generated code uses the classes from the dll instead of creating new types which is what I want.

I can't understand why adding the service reference via Visual Studio is different to using the svcutil. I have tried to find some sort of log/output from the service generation from Visual Studio but I have had no luck. I have tried this in both VS 2012 and VS 2015 Has anyone seen a similar issue to this before, or have any suggestions on what else I can try?

Fishcake
  • 10,496
  • 7
  • 44
  • 72
Steve S
  • 41
  • 1
  • 2
  • 1
    On your client project; go to Service References folder and right click on the service being referenced. Click Configure Service Reference. There should be a Reuse types in specified.. section at the bottom. Select the common.dll to reference. After clicking OK; it will automatically update. – user1628733 Dec 22 '16 at 15:20
  • I have that selected but it sitll creates a new object. I have abstracted it out to a simple project where the custom.dll is the only extrrnal dll I have installed. I have tried both selecting the reuse all referenced types, and reuse the selected referenced types (where common.dll is checked) but in both instances a new object is created. – Steve S Dec 22 '16 at 16:53
  • Yeah that can happen; I forget the reasoning but it is something really simple being overlooked. This post may help you http://stackoverflow.com/questions/8286775/wcf-common-types-not-reused – user1628733 Dec 22 '16 at 19:12
  • Thanks, I had saw that post. I have added the dll before adding the service reference and made sure that the versions betwen the server and the client are the same. I only have access to the dll so can't reference the project in both client/server. I fear that we may have to go down the Channel Factory approach, which would be fine if we were creating a new client but we are migrating an existing client where the service reference is quite substantial so this would require a lot of work. But we may have no other choice. – Steve S Dec 23 '16 at 09:28

0 Answers0