DevFear
Topic Author
Posts: 53
Joined: 29 Jun 2022, 12:36

Geometry.Parse: Native type 'BaseObject' is not registered

08 Jun 2023, 17:36

Hi, this is a rather strange situation.

I work with Geometry from under the code. For personal convenience, I decided to directly process the string and get the geometry through Geometry.Parse("M3..."); However, the method threw an error:
InvalidOperationException: Native type 'BaseObject' is not registered
Noesis.Extend.GetNativeTypeInfo (System.IntPtr nativeType) (at ./NoesisGUI3.2/Runtime/API/Core/Extend.cs:480)
Noesis.Extend.GetNativeTypeInfo (System.IntPtr nativeType) (at ./NoesisGUI3.2/Runtime/API/Core/Extend.cs:476)
Noesis.Extend.GetNativeTypeInfo (System.IntPtr nativeType) (at ./NoesisGUI3.2/Runtime/API/Core/Extend.cs:476)
Noesis.Extend.GetNativeTypeInfo (System.IntPtr nativeType) (at ./NoesisGUI3.2/Runtime/API/Core/Extend.cs:476)
Noesis.Extend.GetNativeTypeInfo (System.IntPtr nativeType) (at ./NoesisGUI3.2/Runtime/API/Core/Extend.cs:476)
Noesis.Extend.GetNativeTypeInfo (System.IntPtr nativeType) (at ./NoesisGUI3.2/Runtime/API/Core/Extend.cs:476)
Noesis.Extend.GetNativeTypeInfo (System.IntPtr nativeType) (at ./NoesisGUI3.2/Runtime/API/Core/Extend.cs:476)
Noesis.Extend.GetNativeTypeInfo (System.IntPtr nativeType) (at ./NoesisGUI3.2/Runtime/API/Core/Extend.cs:476)
Noesis.Extend.GetNativeTypeInfo (System.IntPtr nativeType) (at ./NoesisGUI3.2/Runtime/API/Core/Extend.cs:476)
Noesis.Extend.GetProxy (System.IntPtr cPtr, System.Boolean ownMemory) (at ./NoesisGUI3.2/Runtime/API/Core/Extend.cs:519)
Noesis.Geometry.Parse (System.String source) (at ./NoesisGUI3.2/Runtime/API/Proxies/Geometry.cs:44)
Tester.Awake () (at Assets/Tester.cs:15)
I searched for the reason for a long time until I discovered that Geometry.Parse does not work if Geometry is not loaded from ResourceDictionary at least once before the first call.

An example in which throws an exception:
	private void Awake()
	{
		var geometry1 = Geometry.Parse("M3.91667 13.8333L12.0833 13.8333L12.0833 5.66667L3.91667 5.66667L3.91667 13.8333ZM13.25 4.5L13.25 15L2.75 15L2.75 4.5L13.25 4.5ZM5.08333 11.8442L5.90583 12.6667L8 10.5725L10.0942 12.6667L10.9167 11.8442L8.8225 9.75L10.9167 7.65583L10.0942 6.83333L8 8.9275L5.90583 6.83333L5.08333 7.65583L7.1775 9.75L5.08333 11.8442Z M13.25 2.75L2.75 2.75L2.75 3.91667L13.25 3.91667L13.25 2.75Z M12.6667 1L3.33335 1L3.33335 2.16667L12.6667 2.16667L12.6667 1Z");


		var dictionary = _testResources.Load() as ResourceDictionary;
		var geometry2 = dictionary["TestIcon"] as Geometry;
	}
But! If you write like this, then everything will work:
	private void Awake()
	{
		var dictionary = _testResources.Load() as ResourceDictionary;
		var geometry2 = dictionary["TestIcon"] as Geometry;

		var geometry1 = Geometry.Parse("M3.91667 13.8333L12.0833 13.8333L12.0833 5.66667L3.91667 5.66667L3.91667 13.8333ZM13.25 4.5L13.25 15L2.75 15L2.75 4.5L13.25 4.5ZM5.08333 11.8442L5.90583 12.6667L8 10.5725L10.0942 12.6667L10.9167 11.8442L8.8225 9.75L10.9167 7.65583L10.0942 6.83333L8 8.9275L5.90583 6.83333L5.08333 7.65583L7.1775 9.75L5.08333 11.8442Z M13.25 2.75L2.75 2.75L2.75 3.91667L13.25 3.91667L13.25 2.75Z M12.6667 1L3.33335 1L3.33335 2.16667L12.6667 2.16667L12.6667 1Z");
	}
 
User avatar
sfernandez
Site Admin
Posts: 2997
Joined: 22 Dec 2011, 19:20

Re: Geometry.Parse: Native type 'BaseObject' is not registered

12 Jun 2023, 13:41

Hi, I was able to reproduce this issue. It is happening because if you don't load any xaml before using Noesis API, our plugin does not get correctly initialized.
Could you please report it in our bugtracker?

In the meantime you can just call NoesisUnity.Init() before parsing the geometry.
 
 
User avatar
sfernandez
Site Admin
Posts: 2997
Joined: 22 Dec 2011, 19:20

Re: Geometry.Parse: Native type 'BaseObject' is not registered

03 Jul 2023, 12:12

Thanks for the report.

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 15 guests