xamarin / mac-samples

Sample programs showing how to use Xamarin.Mac on OSX.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SceneKitViewer not running

ddiogo22 opened this issue · comments

A System.Exception is thrown at run-time:

System.Exception: Could not initialize an instance of the type 'Foundation.NSUrl': the native 'initWithString:' method returned nil.
It is possible to ignore this condition by setting MonoTouch.ObjCRuntime.Class.ThrowOnInitFailure to false.
at Foundation.NSObject.InitializeHandle (System.IntPtr handle, System.String initSelector) [0x000ad] in /Users/builder/data/lanes/5489/c4240f3f/source/xamarin-macios/src/Foundation/NSObject2.cs:465
at Foundation.NSUrl..ctor (System.String urlString) [0x00047] in /Users/builder/data/lanes/5489/c4240f3f/source/xamarin-macios/src/build/mac/mobile/Foundation/NSUrl.g.cs:355
at SceneKitViewer.SceneView.LoadScene (System.String path) [0x00001] in /Volumes/Macintosh HD/Users/ddiogo/Developer/Xamarin/Projects/Mac/Xamarin Mac Samples/SceneKitViewer/SceneView.cs:44
at SceneKitViewer.MyDocument.WindowControllerDidLoadNib (AppKit.NSWindowController windowController) [0x00079] in /Volumes/Macintosh HD/Users/ddiogo/Developer/Xamarin/Projects/Mac/Xamarin Mac Samples/SceneKitViewer/MyDocument.cs:50
at at (wrapper managed-to-native) AppKit.NSApplication:NSApplicationMain (int,string[])
at AppKit.NSApplication.Main (System.String[] args) [0x00041] in /Users/builder/data/lanes/5489/c4240f3f/source/xamarin-macios/src/AppKit/NSApplication.cs:100
at SceneKitViewer.AppDelegate.Main (System.String[] args) [0x00007] in /Volumes/Macintosh HD/Users/ddiogo/Developer/Xamarin/Projects/Mac/Xamarin Mac Samples/SceneKitViewer/Main.cs:23

Quick Fix:

SceneView.cs:
(Line 44) Scene = SCNScene.FromUrl (new NSUrl("file://" + path.Replace(" ", "%20") ), (SCNSceneLoadingOptions)null, out error);

Hi @ddiogo22, thanks for calling this out and pointing me in the right direction for a fix. Just committed a fix for it here: #91. Apologies for the slow response on this.