0

I am having a problem running after through the QLPreviewController interface.

view.PushViewController(previewController, true);

QLPreviewController starts up and displays what it should. At this point,

UIApplication.Main(args, null, typeof(AppDelegate));

throws an error


{System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Maui.Controls.Handlers.Compatibility.NavigationRenderer.SecondaryToolbar.LayoutToolbarItems(NFloat toolbarWidth, NFloat toolbarHeight, NFloat padding)
at Microsoft.Maui.Controls.Handlers.Compatibility.NavigationRenderer.SecondaryToolbar.LayoutSubviews()
at UIKit.UIApplication.UIApplicationMain(Int32 argc, String\[\] argv, IntPtr principalClassName, IntPtr delegateClassName)
at UIKit.UIApplication.Main(String\[\] args, Type principalClass, Type delegateClass)
at MAUISample.Program.Main(String\[\] args) in ...MAUISampleProject}

Does anyone know how to fix it or what I might be doing wrong ?

Greetings Matlas

I also tried to open the pdf file through UIDocumentInteractionController. The problem looks the same the file opens but the same error is thrown.

Matlas
  • 1
  • 1
  • 1
    Does this answer your question? [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Ken White Nov 06 '22 at 23:36
  • 1
    Could you provide some code about your use of QLPreviewController? – Zack Nov 07 '22 at 05:13

1 Answers1

0

I have a similar problem and discovered that the root cause was actually in appshell.xml.cs I had to step through the debugger using step into. I would have thought that the exception would have been thrown in appshell and lead me directly there but I didn't discover this until I followed the code by stepping into everything. The problem is related to my code but the exception location is misleading or it was for me.

Brady Guy
  • 1
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 17 '22 at 14:23