"Reuse existing types" is ignored when adding a service reference
Asked Answered
N

2

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?

Novobiocin answered 25/9, 2008 at 15:38 Comment(0)
N
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.

Novobiocin answered 25/9, 2008 at 21:35 Comment(0)
A
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")]
Adley answered 18/11, 2008 at 20:20 Comment(2)
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...Acknowledge
drozzy, attribute is assembly scope, it must placed commonly in assemblyinfo.cs But its not helped to me..Caber

© 2022 - 2024 — McMap. All rights reserved.