Empty reference.cs file adding service reference with reuse types option checked
Asked Answered
K

3

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?

Kappenne answered 14/6, 2011 at 10:57 Comment(6)
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.Signe
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 sideKappenne
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 to the proxy classes.Signe
This is a known problem in VS, bug is even present in VS2008. Perhaps VS2015 will contain some helpful bugfixes...Ely
Check the visual studio output window (NOT the ErrorList), when you try to generate the ServiceReference, do you see any warnings/errors in there?Bipropellant
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.Kappenne
A
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.

Anthracnose answered 19/11, 2012 at 17:45 Comment(0)
E
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.

Exceeding answered 16/8, 2011 at 16:20 Comment(0)
B
0

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

Belgrade answered 30/3, 2012 at 22:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.