开发者

Make Visual Studios "Add Service Reference" Feature use an existing Class

开发者 https://www.devze.com 2022-12-27 07:35 出处:网络
When I add a service referenc开发者_如何学Goe to my Visual Studio 2010 C# project, a new class for one of the types defined in the WSDL will be generated. A de-facto equivalent definition of that type

When I add a service referenc开发者_如何学Goe to my Visual Studio 2010 C# project, a new class for one of the types defined in the WSDL will be generated. A de-facto equivalent definition of that type already exists in our solution in a different assembly.

When adding the SoapTypeAttribute to the existing class and replacing the references to the generated class in the generated code, everything runs perfectly and as expected.

How would I tell Visual Studio to use the existing class in the generated code?


This is not possible... you have to use the Classdefinition of the webservice.

You could try to define an Interface from your Webservice and derive your Class from that interface as a workaround.


Does the "Reuse types in existing assemblies" option not do what you want? (under the Advanced menu)

From the docs it appears that is what you are looking for.

0

精彩评论

暂无评论...
验证码 换一张
取 消