Sometimes Adding a Wcf Service Reference Generates an Empty Reference.Cs

Sometimes adding a WCF Service Reference generates an empty reference.cs

Generally I find that it's a code-gen issue and most of the time it's because I've got a type name conflict it couldn't resolve.

If you right-click on your service reference and click configure and uncheck "Reuse Types in Referenced Assemblies" it'll likely resolve the issue.

If you were using some aspect of this feature, you might need to make sure your names are cleaned up.

Adding Service Reference for WCF Service generates empty reference.cs

You can generate your client proxy with svcutil.exe and use the /r switch to specify assemblies that you want referenced instead of re-emitted in the auto-generated client proxy code.

  • ProjACommon
  • ProjBSvc
    • References ProjACommon
  • ProjCClient
    • References ProjACommon
    • You want a client that references ProjA types and/or code rather than them being auto-generated into a new namespace within C

After building ProjBSvc exec the following, which outputs .wsdl & .xsd

svcutil.exe ProjBSvc.dll

2nd consume the wsdl & xsd to generate a proxy/client:

svcutil.exe *.wsdl *.xsd /o:<ProjCClientPath>/Client.cs /r:ProjACommon.dll

ProjCClient references Client.cs generated from previous steps

Build and examine with the object browser and you will see the types in C referencing the types in A instead of new types with the same name in C's namespace.
You may want /tcv and /n as well as other switches to meet your needs.

Here is an article that may help. It also links to the Microsoft documentation for svcutil

Incorrect WCF Service Reference / Empty Reference.cs file

I came across this question here after researching on this issue.

I also found out that the reference.cs file was empty in my case also. After unchecking Reuse types in referenced assemblies from 'Configure Service Reference' dialog, I was able to generate the Service reference client code successfully. My Service reference is now pointing to the correct Interface/members. In case of any queries, feel free to comment or contact me directly.

WCF Service Reference generates an empty reference.cs due to DuplexBinding

I've solved that.
Empty reference was due to some problems with ambiguous types. When I fixed it, reference.cs file generated well.

So, solution is to look not only at errors, but at warnings too. I have found there all information what I need for my problem. Happy codding

Reference.cs is empty when generating service client

In the Add Service Reference dialog , click on 'Advanced', there uncheck the option 'Reuse reference types in this assembly'

Sample Image

I often encounter this problem, this workaround works most of the times.



Related Topics



Leave a reply



Submit