Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Lost value of string with Xamarin.Android. Not tested yet with iOS. #14281

Open
filmar25 opened this issue May 19, 2021 · 2 comments
Open

Lost value of string with Xamarin.Android. Not tested yet with iOS. #14281

filmar25 opened this issue May 19, 2021 · 2 comments
Labels
external-vs p/Android s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/unverified New report that has yet to be verified t/bug 🐛
Projects

Comments

@filmar25
Copy link

Hi,

I have a weird behavior with Xamarin.Android. I have an exchange with a WCF service and receive a SignedToken, a class defined on the server and generated by svcutil with /async and /tcv:Version35 :

SignedToken contains a string DataExchange defined by :

            private string DataExchangeField;

and accessible by :

            [System.Runtime.Serialization.DataMemberAttribute()]
            public string DataExchange
            {
                get
                {
                    return this.DataExchangeField;
                }
                set
                {
                    this.DataExchangeField = value;
                }
            }

The value from the server is well received in the thread that made the call to the server.

After received SignedToken, I call a function defined like that from the thread that received the answer (RSA is a class we defined to manage RSA exchange with the server on the mobile device (.NET Standard 2.1)) :

            public void SetSignedToken(SignedToken signedToken)
            {
                this.ReplaceSignedTokenValues(signedToken);
            
                if ((this.SignedToken.EncryptedClientToken?.Length ?? 0) > 0)
                {
	                this.DecryptClientToken();
                }
            }
            
            private void ReplaceSignedTokenValues(SignedToken signedToken)
            {
                this.SignedToken.ClientSignature = signedToken.ClientSignature;
                this.SignedToken.EncryptedClientToken = signedToken.EncryptedClientToken;
                this.SignedToken.ServerSignature = signedToken.ServerSignature;
                this.SignedToken.EncryptedServerToken = signedToken.EncryptedServerToken;
                    this.SignedToken.DataExchange = signedToken.DataExchange;
            }

The caller of this function is doing the call like this :

            this.RSA.SetSignedToken(signedToken);
            var mobileUser = this.RSA.GetEncryptedObject<MobileUser>(signedToken.DataExchange);

The weird thing here is : just before exit the SetSignedToken from RSA class, I see the value in this.SignedToken.DataExchange, but after exit the function SetSignedToken via F11 of debugger and arrived to var mobileUser = ... the this.RSA.SignedToken.DataExchange is gone !!

image
image
image

I try to put the value in another property of the SignedToken and the value is preserved. I don't understand why the value of DataExchange is disappearing ?

My configuration is :

i9-9900K
32Gb RAM
VS2019 16.9.5

I have updated all components of my projects to the last version possible.

It is hard to recreate the behavior because of the complexity of the system...

Any help will be appreciated.

Thank you !

@filmar25 filmar25 added s/unverified New report that has yet to be verified t/bug 🐛 labels May 19, 2021
@filmar25
Copy link
Author

Ok, this is creazy !

There is the code that I execute when I receive SignedToken :

		this.RSA.SetSignedToken(signedToken);
		var mobileUser = this.RSA.GetEncryptedObject<MobileUser>();

		if (string.IsNullOrEmpty(signedToken.Message) == false)
		{
			PercentProgress = 1;

			this.Exception = new Exception(signedToken.Message);
			this.Status = ServiceStatus.Idle;
			this.SyncFinished?.Invoke(this, this);
			return;
		}

If I put the breakpoint at

		this.RSA.SetSignedToken(signedToken);

I have the bug, but if I put the breakpoint at

		if (string.IsNullOrEmpty(signedToken.Message) == false)

all is executing like expected.

Something wrong with the debugger ?

@jsuarezruiz jsuarezruiz added this to New in Triage via automation May 21, 2021
@jsuarezruiz
Copy link
Contributor

Still happening in newer VS versions?

@jsuarezruiz jsuarezruiz moved this from New to Needs Info in Triage Sep 7, 2021
@jsuarezruiz jsuarezruiz added external-vs s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. labels Sep 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
external-vs p/Android s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/unverified New report that has yet to be verified t/bug 🐛
Projects
Triage
  
Needs Info
Development

No branches or pull requests

2 participants