This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice This article is not considered official documentation for K2 software and is provided "as is" with no warranties.


When using K2 Studio or K2 for Visual Studio and expanding the SmartObject Server(s) > SmartObject Server from the Object Browser, an "Object Reference not set to an instance of an object" error is displayed and no SmartObjects are visible in any of the Categories.


The following error message may also be displayed:


Troubleshooting Steps


Please note that the following steps are only applicable to K2 4.7 and older. The SQL Query is not compatible with K2 Five.

Execute the following SQL query against the K2 Database:


Use K2 --Change to your K2 Database Name

DECLARE @result1 TABLE (Id INT, CategoryName nvarchar(100), MissingParentID INT)

INSERT INTO @result1

--Select all Categories with missing ParentID
SELECT [Id], [Name],
FROM [Category].[Category]
CROSS APPLY [ParentCategories].nodes('/parentcategory[1]') AS x(r)
WHERE r.value('@id','int') not in (SELECT Id FROM [Category].[Category]);

SELECT * FROM @result1;

--Select any Object currently in the Orphaned Category

SELECT * FROM [Category].[Data]
WHERE [CategoryId] in (SELECT Id FROM @result1);

--Select any Object in category that does not exist
SELECT * FROM [Category].[Data]
WHERE [CategoryId] not in (SELECT Id FROM [Category].[Category]);

--Select any Object that does not exist in category
SELECT * FROM [Category].[Data] WHERE [Data] not in (SELECT [SmartObjectGUID] FROM [SmartBroker].[SmartObject]) AND [DataType] = 'SmartObject'
SELECT * FROM [Category].[Data] WHERE [Data] not in (SELECT [ID] FROM [Form].[Form] UNION SELECT [ID] FROM [Form].[Form_Design]) AND [DataType] = 'Form'
SELECT * FROM [Category].[Data] WHERE [Data] not in (SELECT [ID] FROM [Form].[View] UNION SELECT [ID] FROM [Form].[View_Design]) AND [DataType] = 'View'


Under normal circumstances, no data should be displayed on any of the results.

Should the results display data, it would indicate orphaned Categories and/or K2 Objects, which is the cause of the error.

To resolve this issue, direct database modification will be required. Please log a K2 Support Ticket on the K2 Customer Portal for assistance in resolving the issue. 

Please Note that direct K2 database modification is not allowed as it might leave the environment in an unsupported state. This must only be done with the assistance of, or when instructed to do so by K2 Support.