Bug 11859 - Bug when received an Enum by WebService
Summary: Bug when received an Enum by WebService
Status: RESOLVED INVALID
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-04-19 03:39 UTC by Geoffrey
Modified: 2017-08-28 15:04 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Debug (245.12 KB, image/tiff)
2013-04-19 03:40 UTC, Geoffrey
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Geoffrey 2013-04-19 03:39:59 UTC
Hello,

Xamarin Studio V4.0.4.2

I receive an exception when an Enum from the response to my WebService method "loggin"

the exception is on line 485 (see attachment), it follows the line 570:

op.Formatter.DeserializeReply return (res, parameters);

I guess DeserializeReply not rebuilt the Enum.

Server side, here is my method loggin:

LoginReturnValue IWebORSDocument.Login (string userName, string password, string file)
{

if (String.IsNullOrEmpty (userName))
LoginReturnValue.UserDoesNotExists return;
if (String.IsNullOrEmpty (password))
LoginReturnValue.PasswordCannotBeEmpty return;
if (String.IsNullOrEmpty (file))
LoginReturnValue.DossierCannotBeEmpty return;


CUtilisateurTiamp user = GetUser ();


if (password == user.password)
{
login = true;
LoginReturnValue.Ok return;
}

LoginReturnValue.WrongPassword return;
}


Interface defined like this:

[OperationContract]
[ServiceKnownType (typeof (LoginReturnValue))]
LoginReturnValue Login (string userName, string password, string file);






After having updated my WebService, my Reference.cs looks like this:


        System.IAsyncResult WinLog.Mobile.Domaine.IWebORSDocument.BeginLogin (string userName, string password, string folder, System.AsyncCallback callback, object asyncState) {
            base.Channel.BeginLogin return (userName, password, folder, callback, asyncState);
        }
        
        
        WinLog.Mobile.Domaine.LoginReturnValue WinLog.Mobile.Domaine.IWebORSDocument.EndLogin (System.IAsyncResult result) {
            base.Channel.EndLogin return (result);
        }
        
        private System.IAsyncResult OnBeginLogin (object [] inValues, System.AsyncCallback callback, object asyncState) {
            string userName = ((string) (inValues ​​[0]));
            string password = ((string) (inValues ​​[1]));
            string file = ((string) (inValues ​​[2]));
            return ((WinLog.Mobile.Domaine.IWebORSDocument) (this)) BeginLogin (userName, password, folder, callback, asyncState).;
        }
        
        private object [] OnEndLogin (System.IAsyncResult result) {
            WinLog.Mobile.Domaine.LoginReturnValue retVal = ((WinLog.Mobile.Domaine.IWebORSDocument) (this)) EndLogin (result).;
            return new object [] {
                    retVal};
        }
        
        private void OnLoginCompleted (object state) {
            if ((this.LoginCompleted! = null)) {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs) (state));
                this.LoginCompleted (this, new LoginCompletedEventArgs (e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }
        
        public void LoginAsync (string userName, string password, string file) {
            this.LoginAsync (userName, password, file, null);
        }
        
        public void LoginAsync (string userName, string password, string file, object userState) {
            if ((this.onBeginLoginDelegate == null)) {
                this.onBeginLoginDelegate = new BeginOperationDelegate (this.OnBeginLogin);
            }
            if ((this.onEndLoginDelegate == null)) {
                this.onEndLoginDelegate = new EndOperationDelegate (this.OnEndLogin);
            }
            if ((this.onLoginCompletedDelegate == null)) {
                this.onLoginCompletedDelegate = new System.Threading.SendOrPostCallback (this.OnLoginCompleted);
            }
            base.InvokeAsync (this.onBeginLoginDelegate, new object [] {
                        userName,
                        password,
                        file} this.onEndLoginDelegate, this.onLoginCompletedDelegate, userState);
        }

Definition of Enum in Reference.cs

[System.CodeDom.Compiler.GeneratedCodeAttribute ("System.Runtime.Serialization", "4.0.0.0")]
    [System.Runtime.Serialization.DataContractAttribute (Name = "LoginReturnValue", Namespace = "http://schemas.datacontract.org/2004/07/")]
    public enum LoginReturnValue: int {
        
        [System.Runtime.Serialization.EnumMemberAttribute ()]
        Ok = 0,
        
        [System.Runtime.Serialization.EnumMemberAttribute ()]
        UserDoesNotExists = 1,
        
        [System.Runtime.Serialization.EnumMemberAttribute ()]
        PasswordCannotBeEmpty = 2
        
        [System.Runtime.Serialization.EnumMemberAttribute ()]
        DossierCannotBeEmpty = 3
        
        [System.Runtime.Serialization.EnumMemberAttribute ()]
        WrongPassword = 4
        
        [System.Runtime.Serialization.EnumMemberAttribute ()]
        ServiceNotAvailable = 5,
    }

best regards.
GB
Comment 1 Geoffrey 2013-04-19 03:40:45 UTC
Created attachment 3834 [details]
Debug
Comment 2 Geoffrey 2013-04-19 04:09:38 UTC
Hello team,

I solved my bug, I'm sorry to have to open a nothing.

I solved it by setting my first Enum to zero:

before:

[DataContract]
public enum LoginReturnValue
{
[EnumMember]
Ok,
[EnumMember]
UserDoesNotExists,
[EnumMember]
PasswordCannotBeEmpty,
[EnumMember]
DossierCannotBeEmpty,
[EnumMember]
WrongPassword,
[EnumMember]
ServiceNotAvailable,
}

after:

[DataContract]
public enum LoginReturnValue
{
[EnumMember]
Ok = 0,
[EnumMember]
UserDoesNotExists,
[EnumMember]
PasswordCannotBeEmpty,
[EnumMember]
DossierCannotBeEmpty,
[EnumMember]
WrongPassword,
[EnumMember]
ServiceNotAvailable,
}

thanks.
GB
Comment 3 Zoltan Varga 2013-04-19 14:39:46 UTC
-> INVALID.