5

Scenario

  • Visual Studio 2010
  • Silverlight 4
  • Entity Framework
  • Self-tracking entities

Problem

On the server side, we have generated entity objects using Entity Framework model. We have used self tracking T4 templates to generate the entities. These entities are shared and can be used from the client side (Silverlight 4 project).

But when we try to add a new Web Service reference, the proxy generator don't work. The reference.cs file is empty. We have checked the option 'Reuse Types' in the configuration of the Web Reference. We have checked the assemblies that will be shared (entity assemblies only).

We have tried to remove every (IsReference=true) from DataContract attributes of the entities but it did not work.

Any idea or workaround?

Nadya
  • 51
  • 1
  • 2
  • Just to confirm, the datacontracts are specified by operations on the service? Regardless of whether they are specified as a DataContract, they must be listed as a ServiceOperation parameter/response before they can be generated by adding Service Reference's on the client as far as I know. – Smudge202 Jun 14 '11 at 11:02
  • Yes. We have some methods on the service. Some of them use an entity object as a parameter, others return entity objects. If we uncheck the reuse type option, the proxy generator works fine, but it also generates the entity objects on the client side, we losing the shared assemblies between server side and client side – Nadya Jun 14 '11 at 11:32
  • I've only seen this once before and it was when I had accidentally given a reference to my DAL/Service Library on the client project (add normal reference instead of service reference). I only noticed because this kind of setup did [some strange things](http://stackoverflow.com/questions/6095617/wcf-service-generated-proxy-class-exposing-function-as-byref-sub) to the proxy classes. – Smudge202 Jun 14 '11 at 12:05
  • This is a known problem in VS, bug is even present in VS2008. Perhaps VS2015 will contain some helpful bugfixes... – leppie Jun 14 '11 at 13:06
  • Check the visual studio output window (NOT the ErrorList), when you try to generate the ServiceReference, do you see any warnings/errors in there? – Dominik Jun 30 '11 at 13:25
  • Finally, after a long time on it I could work out a solution. The problem had to do with my VS extensions. I hadn't installed any very odd extension but the problem dissapeared when I uninstalled all my extensions. After that, I reinstalled all them and everything was ok. – Nadya Aug 10 '11 at 08:20

3 Answers3

15

Unchecking the "Reuse Types" worked for me. The code generator walks the object graph of dependencies and if it encounters any problem, like a reference not found, then it blows up and doesn't produce any code in the reference.cs.

Robert Corvus
  • 1,784
  • 18
  • 26
2

This can occur when the assembly your are trying to share is compiled against a higher .NET platform.

For example if your project is targeting .NET 3.5 and the assembly is compiled against 4.0 this will happen.

Chris Hawkins
  • 780
  • 1
  • 5
  • 22
0

You have checked the option Reuse Types? Try uncheck the option Reuse Types

Marcelo Lujan
  • 1,792
  • 15
  • 12