开发者

Why won't VS2010 RC use my existing types when I add a service reference?

I have a huge problem getting services references in VS2010 RC to use existing assemblies.

Even though I have a class library with all the data contracts (classes marked with DataContract and properties with DataMember) that is shared between the service project and the consuming project (which is a class library), when I add a service reference, the data contracts are regenerated withing the service reference instead of using the existing types.

When I was using VS2010 beta 2, this worked fine, and I have existing service references using the very same data contracts. But if I add a new service reference, or even update an old one, it won't use the existing types anymore.

I have made a mini-test-solution, with one service, one d开发者_开发知识库ata contract type and one console app as a consumer (all in the same solution), and there it seems to work, but that's no great comfort to me. Is there any way to see why it can't use the existing types?

Edit to clearify. It works to generate the proxy classes with svcutil.exe, and point to the data contracts dll, like this:

svcutil.exe http://localhost/MyService.svc
/reference:[Path To DataContracts]\DataContracts.dll 
/n:*,MyProject.MyServiceReference /ct:System.Collections.Generic.List`1

The question is, what possible reason could there be for Visual Studio to generate its own datacontracts instead of using the existing ones even though the "reuse" checkbox is checked and the datacontracts assembly is referenced.


I have had this problem with VS 2008 in the past. Although I wasnt able to find the reason why it doesnt pick up types from the very same assembly you are adding the service reference to I did notice that it works if you actually take the DataContracts out. As in put them in a separate dll and then reference that dll to your project where you are adding the service reference. In most case this is a more elegant solution anyway as people tend to share the DataContracts between the service and the service consumer.


When you add a Service Reference there is a checkbox, that indicates if you want to generate the data contracts or use existing types.

I have not checked, but the default of this may have changed, which would explain your problem.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜