StatusException [BadTypeDefinitionInvalid] when calling BaseNodeManager.CreateObject

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
jramirez-jh
Hero Member
Hero Member
Posts: 21
Joined: 14 Jun 2021, 23:39

StatusException [BadTypeDefinitionInvalid] when calling BaseNodeManager.CreateObject

Post by jramirez-jh »

I'm getting an exception of type StatusException with message "[BadTypeDefinitionInvalid]" when trying to create an object from my exported UA Modeler definitions.

Example of my code:

Code: Select all

internal partial class test21_NsNodeManager : BaseNodeManager
{
	public test21_NsNodeManager(ServerManager server) : base(server)
	{
	}
	
	public override void Startup()
	{
		try
		{
			DefaultNamespaceIndex = AddNamespaceUri("http://test.com/test21/");

			ImportUaNodeset(Assembly.GetEntryAssembly(), "test21.xml");

			var settings = new CreateObjectSettings()
			{
				ParentNodeId = UnifiedAutomation.UaBase.ObjectIds.ObjectsFolder,
				ReferenceTypeId = UnifiedAutomation.UaBase.ReferenceTypeIds.Organizes,
				RequestedNodeId = new NodeId("myobject_1", DefaultNamespaceIndex),
				BrowseName = new QualifiedName("myobject_1", DefaultNamespaceIndex),
				TypeDefinitionId = ObjectTypeIds.MyObject_Custom_v1.ToNodeId(Server.NamespaceUris)
			};

			var theObject = CreateObject(Server.DefaultRequestContext, settings); //<-- throwing exception!
		}
		catch (Exception e)
		{
			Console.WriteLine("Failed to start test21_NsNodeManager " + e.Message);
		}
	}

	public override void Shutdown()
	{
		//Some code
	}
}
No idea what's missing here.

User avatar
Support Team
Hero Member
Hero Member
Posts: 3064
Joined: 18 Mar 2011, 15:09

Re: StatusException [BadTypeDefinitionInvalid] when calling BaseNodeManager.CreateObject

Post by Support Team »

Hello,

We cannot reproduce this issue. Please create a support ticket (https://webdav.unifiedautomation.com/support/support_form.html) and attach the NodeSet2 XML file. This will help us analysing this issue.
Best regards
Unified Automation Support Team

jramirez-jh
Hero Member
Hero Member
Posts: 21
Joined: 14 Jun 2021, 23:39

Re: StatusException [BadTypeDefinitionInvalid] when calling BaseNodeManager.CreateObject

Post by jramirez-jh »

We have already handled this trought the support ticket and you helped us to find the issue.

If some future user faces the same issue: The problem was caused because one variable from an Object was not set to a valid TypeDefinition. Just open your OPC-UA Model in the UA Modeler and verify the TypeDefinition for each variable, normally it needs to be "BaseDataVariableType". Once it's fixed export again your classes.

Regards.

Post Reply