1

So I have a project I've inherited that has a WCF Service Reference and the corresponding Reference.cs generated proxy classes. In the existing proxy classes I can see an enum defintion:

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="MyRecord.ColorAction", Namespace="http://schemas.datacontract.org/2004/07/DocumentsDataAccess.DataClasses")]
public enum ColorAction : int {

    [System.Runtime.Serialization.EnumMemberAttribute()]
    NONE = 0,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    GREEN = 1,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    RED = 2,

}

Here is the corresponding WCF code:

[DataContract]
public enum ColorAction
{
    [EnumMember]
    NONE = 0,
    [EnumMember]
    GREEN = 1,
    [EnumMember]
    RED = 2,
}

I can verify this is exposed by looking at the wsdl in a browser and I can see the enum types listed.

However, when I either 'refresh' or 'Add Service Reference' (as a new reference by deleting and re-adding), this enum along with a lot of other methods and enums are missing. The download and creation of the proxy classes is successful so it's not an issue of an error.

I have tried adjusting all of the 'Advanced' settings in the Add Service Reference dialog, but it seems to make no difference. The net result is since existing code is expecting to be able to call and use the enums among other code that's missing, the code will not compile after refreshing or re-adding the service reference.

I've already tried unchecking Reuse types in all referenced assemblies but that did not change the outcome.

I'm wondering, did the original person that created the proxy classes I'm looking at not use the Add Service Reference wizard and went directly to use SvcUtil.exe instead? I've used it before myself, but wondering is that what I need to use that will generate everything the WCF service is exposing? What switches would I need to get everything the service has to publicly offer? (FYI, I'm targeting .NET 4.0).

atconway
  • 20,624
  • 30
  • 159
  • 229

1 Answers1

1

Can you post the hosting WCF service code for the Enum class?

Add Service Reference may not create a complete reference file SO-SvcUtil.exe vs Add Reference. It's possible that SvcUtil.exe was used instead. Try that and see if that builds a better proxy.

Community
  • 1
  • 1
Stinky Towel
  • 768
  • 6
  • 26
  • Is the enum class used in any methods on the WCF side? It must be part of the contract - see [here](http://stackoverflow.com/questions/6098800/datacontract-for-enums-in-wcf) – Stinky Towel Oct 31 '13 at 16:29
  • Enums are pulled in using `Add Service Reference` in VS2010 but not in VS2012. Any idea on why the IDE change would create different proxies even though the same options were used to create them? – atconway Nov 08 '13 at 16:19
  • @atconway - Can you clarify what you mean 'pulled in VS2010 but not in VS2012"? Any chance the project you inherited targeted an earlier FW, like 3.5? When you unchecked "Reuse types in all referenced assemblies" did you then select the corresponding assemblies you needed? – Stinky Towel Nov 08 '13 at 17:29
  • By pulled in I mean 'created in the proxy classes'. So in VS2010 the enums were created in the proxy classes but not in the proxy classes in VS2012 using the _exact_ same options in the `Add Service Reference` dialog. I didn't check any of the assemblies in either version of VS.NET after deselecting 'Reuse...' – atconway Nov 08 '13 at 18:36
  • Try hand selecting the assemblies. Can you compare the reference.cs files between the original and your refreshed version. Are there any diffs? Are the namespaces intact? – Stinky Towel Nov 09 '13 at 00:23