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

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

Open
3 tasks
divyesh008 opened this issue Aug 4, 2020 · 1 comment

Comments

@divyesh008
Copy link

divyesh008 commented Aug 4, 2020

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

  • nuget version = 1.7.0
  • component version =
  • sample

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:

  • [] .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

LinkedIn, Insta and Facebook login succeeds

Actual behaviour

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

@CoeqWEty
Copy link

CoeqWEty commented Aug 4, 2020 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants