Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xamarin.Forms + NullGuard = crash at startup #93

Closed
megafinz opened this issue Nov 14, 2017 · 2 comments · Fixed by #95
Closed

Xamarin.Forms + NullGuard = crash at startup #93

megafinz opened this issue Nov 14, 2017 · 2 comments · Fixed by #95
Milestone

Comments

@megafinz
Copy link

Hi.

I'm getting a crash at startup when I add NullGuard.Fody to my Xamarin.Forms project.

Steps to reproduce (using VS 2017 for Mac):

  1. File -> New Solution -> Blank Forms App (C#) -> (doesn't matter if Shared Project / PCL or XAML / no XAML).
  2. *.iOS -> Packages -> Add Packages -> NullGuard.Fody.
  3. Add <NullGuard /> to FodyWeavers.xml.
  4. Run the iOS app.
  5. Crash (see below).

I'm using:

  • Fody 2.1.2
  • NullGuard.Fody 1.6.2
  • Visual Studio Community 2017 for Mac (7.3 build 740)
  • Xamarin.iOS 11.4.0.214
  • Xamarin.Forms 2.4.0.280

Exception:

System.MethodAccessException: Method `System.Diagnostics.Private.Debug:Assert (bool,string)' is inaccessible from method `NullGuardTest.iOS.AppDelegate:FinishedLaunching (UIKit.UIApplication,Foundation.NSDictionary)'
  at at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_throw_method_access (intptr,intptr)
  at NullGuardTest.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00048] in /Users/megafinz/Projects/NullGuardTest/iOS/AppDelegate.cs:14
  at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/5489/25c6ba1e/source/xamarin-macios/src/UIKit/UIApplication.cs:79
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/5489/25c6ba1e/source/xamarin-macios/src/UIKit/UIApplication.cs:63
  at NullGuardTest.iOS.Application.Main (System.String[] args) [0x00001] in /Users/megafinz/Projects/NullGuardTest/iOS/Main.cs:17
@tom-englert
Copy link
Member

If "Debug.Assert" is not accessible in IOS, you can turn it off in configuration: IncludeDebugAssert="false"
see https://github.com/Fody/NullGuard#configuration

@megafinz
Copy link
Author

Disabling Debug.Assert in configuration fixes the issue.

I tried using System.Diagnostics.Debug.Assert and it compiles and works fine, so Debug.Assert is in fact accessible. Exception message says that System.Diagnostics.**Private**.Debug.Assert is being used, maybe this is the source of the issue.

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

Successfully merging a pull request may close this issue.

2 participants