Forum Libraries, Components, and Plugins


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

5.2.2 Update to ACR.Dialogs breaks existing code

MarthughieMarthughie GBMember ✭✭

I have a general purpose routine which shows a dialog and gets an OK/Cancel/Text input. Since updating to 5.2.2 this has stopped working and throws a null reference exception

            PromptConfig pcfg = new PromptConfig();
            pcfg.Message = strMess;
            pcfg.Title = strTitle;
            pcfg.OkText = strOK;

            // get result
            pr = await UserDialogs.Instance.PromptAsync(pcfg);

The last line throws the exception.

I have looked at the sample code, but that does not offer any clues. I have tried passing a cancelation token into UserDialogs.Instance.PromptAsync as well but this does not help.

Any ideas what is causing this?


Exception details
{System.NullReferenceException: Object reference not set to an instance of an object
at Acr.Support.iOS.Extensions.GetTopViewController (UIKit.UIApplication app) [0x00006] in :0
at Acr.UserDialogs.UserDialogsImpl+<>c__DisplayClass19_0.b__0 () [0x00000] in C:\dev\modules\userdialogs\src\Acr.UserDialogs.iOS\UserDialogsImpl.cs:248
at Foundation.NSActionDispatcher.Apply () [0x00000] in /Users/builder/data/lanes/3234/d8bedd03/source/maccore/src/Foundation/NSAction.cs:57
at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSend_IntPtr_IntPtr_bool (intptr,intptr,intptr,intptr,bool)
at Foundation.NSObject.InvokeOnMainThread (System.Action action) [0x00007] in /Users/builder/data/lanes/3234/d8bedd03/source/maccore/src/Foundation/NSObject2.cs:544
at Acr.UserDialogs.UserDialogsImpl.Present (UIKit.UIAlertController alert) [0x00018] in C:\dev\modules\userdialogs\src\Acr.UserDialogs.iOS\UserDialogsImpl.cs:246
at Acr.UserDialogs.UserDialogsImpl.Prompt (Acr.UserDialogs.PromptConfig config) [0x000a9] in C:\dev\modules\userdialogs\src\Acr.UserDialogs.iOS\UserDialogsImpl.cs:142
at Acr.UserDialogs.AbstractUserDialogs.PromptAsync (Acr.UserDialogs.PromptConfig config, Nullable`1 cancelToken) [0x00023] in C:\dev\modules\userdialogs\src\Acr.UserDialogs.Interface\AbstractUserDialogs.cs:256
at atereo.Utils_UserPrompt_PS+c__async1.MoveNext () [0x000b3] in /Users/BTS/Projects/May4thbackup - plANbsrcCHANGE/atereo/Utils_UserPrompt_PS.cs:97 }
Data: Count = 0
HResult: -2147467261
HelpLink: (null)
InnerException: (null)
Message: "Object reference not set to an instance of an object"
Source: "Acr.Support.iOS"
StackTrace: " at Acr.Support.iOS.Extensions.GetTopViewController (UIKit.UIApplication app) [0x00006] in :0 \n at Acr.UserDialogs.UserDialogsImpl+<>c__DisplayClass19_0.b__0 () [0x00000] }



  • AllanRitchieAllanRitchie CAInsider, University ✭✭✭

    This actually doesn't look like an issue with 5.2.2 specifically. It looks like it is failing trying to get the top viewcontroller which is usually caused by calling for the dialog before a viewcontroller is ready to present.

    You should file issues like this on github as that is the support channel I use. While I do monitor for issues on the forums, it is sometimes missed here.

  • MarthughieMarthughie GBMember ✭✭
    edited June 2016

    Thanks for commenting Allan. The only reason I suspected 5.2.2 was that the code base has worked fine for months, and I chose today to update the package, and it immediately ran into problems.

    Edit: Just checked the code. The App window hierarchy is loaded. The call to the Acr.UserDialogs library is being made from the ViewDidLoad of a UIViewController, which in turn has been loaded by a UITabBarController which is the top view controller.

  • MarthughieMarthughie GBMember ✭✭

    Am I right that there is still no initialisation call required for iOS implementations ? (I am not making one currently)

  • MarthughieMarthughie GBMember ✭✭

    I have just rolled back to the backup I did before the update. Dialogs 4.3.4 and .Support 1.1.1

    The same code works fine.

    Any ideas please.

  • KarlKoppKarlKopp AUMember ✭✭

    Hey @Marthughie did u ever get to the bottom of this?

Sign In or Register to comment.