5

I am adding a service reference to one of my projects in Visual Studio 2008. On the "Service Reference Settings" screen I am selecting the default option which says "Reuse types in all referenced assemblies". I have referenced the project for which I want to reuse a type. That type is being passed in as a parameter to a web method.

However, when the References.cs file is generated, it still creates a duplicate proxy version of that type. Is there something I am missing? Do you need to do anything special to the referenced type? Perhaps add some special attributes?

jeremcc
  • 8,633
  • 11
  • 45
  • 55

2 Answers2

6

I've answered my own question (I think). What I was trying to do was use a service reference to point to an existing ASP.NET web service, but reusing types is not supported for old school web services. It only works with WCF services. So I took the plunge and converted my web service to a true WCF service and now it works fine.

jeremcc
  • 8,633
  • 11
  • 45
  • 55
5

I had a similar problem until I defined the following attribute in the code so that the namespace of the objects related to the service contract were set to the same namespace as the commonly referenced types.

[assembly: ContractNamespace("YOUR_NAMESPACE_HERE")]
Rich Reuter
  • 612
  • 5
  • 9
  • Where did you set this? On Interface of the service, or the implementing class? Both give me an error saying it's an invalid place to put the attribute... – Andriy Drozdyuk Mar 27 '13 at 15:20
  • drozzy, attribute is assembly scope, it must placed commonly in assemblyinfo.cs But its not helped to me.. – gdbdable Jul 18 '13 at 10:00