user2788317
user2788317

Reputation: 3

enum integer values change after compile c# 2.0

i have these code at my core application

[System.Serializable()]
public enum FieldOfDiscipline : int
{
None = 0,
ArchitecturalEngineeringFacilitiesManagement = 1,
ArtsLibraryScienceServices = 2,
AssetManagement = 3,
BusinessCorporatePlanning = 4,
DataStatistics = 5,
ExecutiveAssistance = 6,
FinancialServices = 7,
HealthServices = 8,
HumanResourceTrainingServices = 9,
InformationTechnologyServices = 10,
InternalAudit = 11,
InternationalOperations = 12,
LegalInvestigationServices = 13,
LoansCreditOperations = 14,         
ManagerialExecutive = 15,
PaymentsSettlements = 16,
ProcurementServices = 17,
PublicRelationsCommunications = 18,
ResearchDevelopment = 19,
Others = 255
}

im using it in my web service

now when i reference my web service and use the enum in my web application it is giving me a different integer value, so i investigated to go to the definition i was referenced to this

#region Assembly App_WebReferences.3joumvby.dll, v2.0.50727
// C:\Users\Carlo\AppData\Local\Temp\Temporary ASP.NET Files\bsper.website\6db12346\_shadow\6f228f03\286299993\30323649\App_WebReferences.3joumvby.dll
#endregion

using System;
using System.CodeDom.Compiler;
using System.Xml.Serialization;

namespace BSPeR.ApplicationServiceProvider
{
    [Serializable]
    [XmlType(Namespace = "http://tempuri.org/")]
    [GeneratedCode("System.Xml", "4.0.30319.2022")]
    public enum FieldOfDiscipline
    {
        None = 0,
        ArchitecturalEngineeringFacilitiesManagement = 1,
        ArtsLibraryScienceServices = 2,
        AssetManagement = 3,
        BusinessCorporatePlanning = 4,
        DataStatistics = 5,
        ExecutiveAssistance = 6,
        FinancialServices = 7,
        HealthServices = 8,
        HumanResourceTrainingServices = 9,
        InformationTechnologyServices = 10,
        InternalAudit = 11,
        InternationalOperations = 12,
        LegalInvestigationServices = 13,
        LoansCreditOperations = 14,
        ManagerialExecutive = 15,
        PaymentsSettlements = 16,
        ProcurementServices = 17,
        PublicRelationsCommunications = 18,
        ResearchDevelopment = 19,
        Others = 20,
    }
}

Noticed the integer value of Others? It was changed to 20 from 255.

for e.g when I use this code

(int) FieldOfDiscipline.Others it will return an integer value of 20 instead of 255

How can I get the original value or the value that I've assigned?

Upvotes: 0

Views: 242

Answers (1)

Rob Potter
Rob Potter

Reputation: 1018

WSDL uses XML schema to describe datatypes. A .NET enum (int and label) has no directly equivalent XML schema datatype and so .NET represents an enum as a set of labels. Therefore, the int values do not appear in the service description (WSDL + XSD) of your web service. I can only assume that the client proxy generation process (svcutil I assume) has generated its own int values.

Also see this for a similar Java question: Enum Type in WSDL representation

Upvotes: 1

Related Questions