xamarin / Xamarin.Auth

Xamarin.Auth
Apache License 2.0
542 stars 350 forks source link

Getting System.TypeInitializationException: The type initializer for 'IOS' threw an exception in iOS 13 after updating Visual studio and macOS #447

Open divyesh008 opened 4 years ago

divyesh008 commented 4 years ago

Xamarin.Auth Issue

Note: I have added --optimize=force-rejected-types-removal in additional mtouch argument with linker behavior Link from sdk only to forcefully remove trace of deprecated UIWebView.

When code executes this line:

rc.PresentViewController(auth.GetUI(), true, null);

{System.TypeInitializationException: The type initializer for 'IOS' threw an exception. ---> System.NotSupportedException: Linked Away
  at UIKit.DeprecatedWebView..ctor (CoreGraphics.CGRect ) [0x00000] in 
  /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.3.2/src/Xamarin.iOS/UIWebView.g.cs:99 
  at Xamarin.Auth.WebViewConfiguration+IOS.UserAgentFromUIWebView () [0x00000] in <85539ee049364f3e8d64880a4a42b589>:0 
  at Xamarin.Auth.WebViewConfiguration+IOS..cctor () [0x00041] in <85539ee049364f3e8d64880a4a42b589>:0 
   --- End of inner exception stack trace ---
  at Xamarin.Auth.WebAuthenticatorController..ctor (Xamarin.Auth.WebAuthenticator authenticator) [0x00000] in <85539ee049364f3e8d64880a4a42b589>:0 
  at Xamarin.Auth.WebAuthenticator.GetPlatformUIEmbeddedBrowser () [0x00002] in <85539ee049364f3e8d64880a4a42b589>:0 
  at Xamarin.Auth.WebAuthenticator.GetPlatformUI () [0x000c3] in <85539ee049364f3e8d64880a4a42b589>:0 
  at Xamarin.Auth.Authenticator.GetUI () [0x00000] in <85539ee049364f3e8d64880a4a42b589>:0 
  at MyApp.iOS.RendererClasses.AuthenticationButtonRenderer.LinkedIn_call   }

OR

var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
presenter.Login(auth); 
{System.TypeInitializationException: The type initializer for 'IOS' threw an exception. ---> 
System.NotSupportedException: Linked Away
  at UIKit.DeprecatedWebView..ctor (CoreGraphics.CGRect ) 
  [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.3.2/src/Xamarin.iOS/UIWebView.g.cs:99 
  at Xamarin.Auth.WebViewConfiguration+IOS.UserAgentFromUIWebView () [0x00000] in <85539ee049364f3e8d64880a4a42b589>:0 
  at Xamarin.Auth.WebViewConfiguration+IOS..cctor () [0x00041] in <85539ee049364f3e8d64880a4a42b589>:0 
   --- End of inner exception stack trace ---
  at Xamarin.Auth.WebAuthenticatorController..ctor (Xamarin.Auth.WebAuthenticator authenticator) [0x00000] in <85539ee049364f3e8d64880a4a42b589>:0 
  at Xamarin.Auth.WebAuthenticator.GetPlatformUIEmbeddedBrowser () [0x00002] in <85539ee049364f3e8d64880a4a42b589>:0 
  at Xamarin.Auth.WebAuthenticator.GetPlatformUI () [0x000c3] in <85539ee049364f3e8d64880a4a42b589>:0 
  at Xamarin.Auth.Authenticator.GetUI () [0x00000] in <85539ee049364f3e8d64880a4a42b589>:0 
  at Xamarin.Auth.Presenters.XamarinIOS.PlatformOAuthLoginPresenter.Login (Xamarin.Auth.Authenticator authenticator) [0x00027] 
  in <85539ee049364f3e8d64880a4a42b589>:0 
  at Xamarin.Auth.Presenters.XamarinIOS.AuthenticationConfiguration+<>c.<Init>b__0_0 (Xamarin.Auth.Authenticator authenticator) 
  [0x00006] in <85539ee049364f3e8d64880a4a42b589>:0 
  at Xamarin.Auth.Presenters.OAuthLoginPresenter.Login (Xamarin.Auth.Authenticator authenticator) [0x00012] in <85539ee049364f3e8d64880a4a42b589>:0 
  at MyApp.iOS.RendererClasses.AuthenticationButtonRenderer.LinkedIn_call (MyApp.CustomControls.AuthenticationButton view) 
  [0x00175] in  }

Stack trace:

"  at Xamarin.Auth.WebAuthenticatorController..ctor (Xamarin.Auth.WebAuthenticator authenticator) [0x00000] 
in <85539ee049364f3e8d64880a4a42b589>:0 \n  at Xamarin.Auth.WebAuthenticator.GetPlatformUIEmbeddedBrowser () 
.[0x00002] in <85539ee049364f3e8d64880a4a42b589>:0 \n  at Xamarin.Auth.WebAuthenticator.GetPlatformUI () [0x000c3] 
in <85539ee049364f3e8d64880a4a42b589>:0 \n  at Xamarin.Auth.Authenticator.GetUI () [0x00000] in 
<85539ee049364f3e8d64880a4a42b589>:0 \n  at Xamarin.Auth.Presenters.XamarinIOS.PlatformOAuthLoginPresenter.Login 
(Xamarin.Auth.Authenticator authenticator) [0x00027] in <85539ee049364f3e8d64880a4a42b589>:0 \n  
at Xamarin.Auth.Presenters.XamarinIOS.AuthenticationConfiguration+<>c.<Init>b__0_0 (Xamarin.Auth.Authenticator authenticator)
[0x00006] in <85539ee049364f3e8d64880a4a42b589>:0 \n  at Xamarin.Auth.Presenters.OAuthLoginPresenter.Login 
(Xamarin.Auth.Authenticator authenticator) [0x00012] in <85539ee049364f3e8d64880a4a42b589>:0 \n  
at Coeqwety.iOS.RendererClasses.AuthenticationButtonRenderer.LinkedIn_call (Coeqwety.CustomControls.AuthenticationButton view)
[0x00169] in /Users/differenz159/Documents/Sourcetree/Coeqwety_git/Coeqwety/Coeqwety.iOS/RendererClasses/AuthenticationButtonRenderer.cs:230 "

IF BUG, INCLUDE THIS PART:

Version

Steps to reproduce

  1. Perform authentication steps as mentioned in this nuget's readme
  2. Add --optimize=force-rejected-types-removal mtouch argument with Link from sdk only linker behavior
  3. Execute: rc.PresentViewController(auth.GetUI(), true, null);

Platform:

Expected behaviour

LinkedIn, Insta and Facebook login succeeds

Actual behaviour

Application crash with System.TypeInitializationException: The type initializer for 'IOS' threw an exception

CoeqWEty commented 4 years ago

Thanks Divyesh. !!

Sent from my iPhone

On Aug 3, 2020, at 11:44 PM, Divyesh notifications@github.com wrote:

 Xamarin.Auth Issue

Note: I have added --optimize=force-rejected-types-removal in additional mtouch argument with linker behavior Link from sdk only to forcefully remove trace of deprecated UIWebView.

When code executes this line:

rc.PresentViewController(auth.GetUI(), true, null);

{System.TypeInitializationException: The type initializer for 'IOS' threw an exception. ---> System.NotSupportedException: Linked Away at UIKit.DeprecatedWebView..ctor (CoreGraphics.CGRect ) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.3.2/src/Xamarin.iOS/UIWebView.g.cs:99 at Xamarin.Auth.WebViewConfiguration+IOS.UserAgentFromUIWebView () [0x00000] in <85539ee049364f3e8d64880a4a42b589>:0 at Xamarin.Auth.WebViewConfiguration+IOS..cctor () [0x00041] in <85539ee049364f3e8d64880a4a42b589>:0 --- End of inner exception stack trace --- at Xamarin.Auth.WebAuthenticatorController..ctor (Xamarin.Auth.WebAuthenticator authenticator) [0x00000] in <85539ee049364f3e8d64880a4a42b589>:0 at Xamarin.Auth.WebAuthenticator.GetPlatformUIEmbeddedBrowser () [0x00002] in <85539ee049364f3e8d64880a4a42b589>:0 at Xamarin.Auth.WebAuthenticator.GetPlatformUI () [0x000c3] in <85539ee049364f3e8d64880a4a42b589>:0 at Xamarin.Auth.Authenticator.GetUI () [0x00000] in <85539ee049364f3e8d64880a4a42b589>:0 at MyApp.iOS.RendererClasses.AuthenticationButtonRenderer.LinkedIn_call } OR

var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(auth); {System.TypeInitializationException: The type initializer for 'IOS' threw an exception. ---> System.NotSupportedException: Linked Away at UIKit.DeprecatedWebView..ctor (CoreGraphics.CGRect ) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.3.2/src/Xamarin.iOS/UIWebView.g.cs:99 at Xamarin.Auth.WebViewConfiguration+IOS.UserAgentFromUIWebView () [0x00000] in <85539ee049364f3e8d64880a4a42b589>:0 at Xamarin.Auth.WebViewConfiguration+IOS..cctor () [0x00041] in <85539ee049364f3e8d64880a4a42b589>:0 --- End of inner exception stack trace --- at Xamarin.Auth.WebAuthenticatorController..ctor (Xamarin.Auth.WebAuthenticator authenticator) [0x00000] in <85539ee049364f3e8d64880a4a42b589>:0 at Xamarin.Auth.WebAuthenticator.GetPlatformUIEmbeddedBrowser () [0x00002] in <85539ee049364f3e8d64880a4a42b589>:0 at Xamarin.Auth.WebAuthenticator.GetPlatformUI () [0x000c3] in <85539ee049364f3e8d64880a4a42b589>:0 at Xamarin.Auth.Authenticator.GetUI () [0x00000] in <85539ee049364f3e8d64880a4a42b589>:0 at Xamarin.Auth.Presenters.XamarinIOS.PlatformOAuthLoginPresenter.Login (Xamarin.Auth.Authenticator authenticator) [0x00027] in <85539ee049364f3e8d64880a4a42b589>:0 at Xamarin.Auth.Presenters.XamarinIOS.AuthenticationConfiguration+<>c.b__0_0 (Xamarin.Auth.Authenticator authenticator) [0x00006] in <85539ee049364f3e8d64880a4a42b589>:0 at Xamarin.Auth.Presenters.OAuthLoginPresenter.Login (Xamarin.Auth.Authenticator authenticator) [0x00012] in <85539ee049364f3e8d64880a4a42b589>:0 at MyApp.iOS.RendererClasses.AuthenticationButtonRenderer.LinkedIn_call (MyApp.CustomControls.AuthenticationButton view) [0x00175] in } Stack trace:

" at Xamarin.Auth.WebAuthenticatorController..ctor (Xamarin.Auth.WebAuthenticator authenticator) [0x00000] in <85539ee049364f3e8d64880a4a42b589>:0 \n at Xamarin.Auth.WebAuthenticator.GetPlatformUIEmbeddedBrowser () .[0x00002] in <85539ee049364f3e8d64880a4a42b589>:0 \n at Xamarin.Auth.WebAuthenticator.GetPlatformUI () [0x000c3] in <85539ee049364f3e8d64880a4a42b589>:0 \n at Xamarin.Auth.Authenticator.GetUI () [0x00000] in

<85539ee049364f3e8d64880a4a42b589>:0 \n at Xamarin.Auth.Presenters.XamarinIOS.PlatformOAuthLoginPresenter.Login (Xamarin.Auth.Authenticator authenticator) [0x00027] in <85539ee049364f3e8d64880a4a42b589>:0 \n at Xamarin.Auth.Presenters.XamarinIOS.AuthenticationConfiguration+<>c.b__0_0 (Xamarin.Auth.Authenticator authenticator) [0x00006] in <85539ee049364f3e8d64880a4a42b589>:0 \n at Xamarin.Auth.Presenters.OAuthLoginPresenter.Login (Xamarin.Auth.Authenticator authenticator) [0x00012] in <85539ee049364f3e8d64880a4a42b589>:0 \n at Coeqwety.iOS.RendererClasses.AuthenticationButtonRenderer.LinkedIn_call (Coeqwety.CustomControls.AuthenticationButton view) [0x00169] in /Users/differenz159/Documents/Sourcetree/Coeqwety_git/Coeqwety/Coeqwety.iOS/RendererClasses/AuthenticationButtonRenderer.cs:230 " IF BUG, INCLUDE THIS PART: Version nuget version = 1.6.0.4 component version = sample Steps to reproduce Perform authentication steps as mentioned in this nuget's readme Add --optimize=force-rejected-types-removal mtouch argument with Link from sdk only linker behavior Execute: rc.PresentViewController(auth.GetUI(), true, null); Platform: [] .NET version = .NET Core Runtime: 3.1.6 / .NET Core SDK: 3.1.302 [] mono version = 6.10.0.106 Xamarin.iOS Version: 13.18.3.2 (Visual Studio Community) Expected behaviour It should of WebUI for social login, in my case LinkedIn Login page Actual behaviour Tell us what happens instead Can you also include a screen shot? Application crash with System.TypeInitializationException: The type initializer for 'IOS' threw an exception IF IT IS A NEW FEATURE REQUEST, INCLUDE THIS PART: Feature description This should work like when I click open social login it should open it's WebView UI and after successful authentication it should close the web page and redirect user to next screen with details. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.