Fixing ‘State code or status code is invalid’ errors when deleting solutions in Dynamics CRM 2011

Working with Dynamics CRM 2011, I started getting an error when attempting to delete a managed solution:

Error deleting a managed solution: State code or status code is invalid
State code is invalid or state code is valid but status code is invalid for a specified state code.

The ErrorDetails.txt file states the following — note the text in bold.

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: 1 is not a valid status code for state code SavedQueryState.Inactive on savedquery.Detail:

Error Code -2147187704

CallStack
at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)
at Microsoft.Crm.Extensibility.Pipeline.Execute(PipelineExecutionContext context)
at Microsoft.Crm.Extensibility.MessageProcessor.Execute(PipelineExecutionContext context)
at Microsoft.Crm.Extensibility.InternalMessageDispatcher.Execute(PipelineExecutionContext context)
at Microsoft.Crm.Extensibility.ExternalMessageDispatcher.ExecuteInternal(IInProcessOrganizationServiceFactory serviceFactory, IPlatformMessageDispatcherFactory dispatcherFactory, String messageName, String requestName, Int32 primaryObjectTypeCode, Int32 secondaryObjectTypeCode, ParameterCollection fields, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId, Guid transactionContextId, Int32 invocationSource, Nullable`1 requestId, Version endpointVersion)
at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.ExecuteRequest(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType)
at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.Execute(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType)

This error came about after we marked some of the out-of-the-box views as Inactive (like “Accounts: Responded to Campaigns in Last 6 Months”). Looking at the database, the statecode (Status) and statuscode (Status Reason) for these views (in table SavedQueryBase) were both “1”. There was a simple workaround to this: change the statuscode to “2”, using the following SQL.

update savedquerybase
set statuscode = 2
where statuscode = 1
and statecode = 1

That allowed the solution to delete without error, and the views I wanted inactivated were still inactive. Seems a bug in Dynamics CRM 2011, but I can’t say for sure.

Of course, use this as your own risk!

Can’t install TFS, or the .Net Framework, or almost anything? Check your security policies!

On a newly-rebuild Windows 2003 server, I set out to install TFS 2008. After installing SQL 2005, and SQL Reporting Services, and SQL Analysis Services, and SQL 2005 Service Pack 3, I fired up the TFS installer, only to ultimately get the dreaded “Send Report/Don’t Send Report” dialog box.

Team Foundation Server encountered a problem during setup

Nice! Looking at the install log was so much more revealing.

[09/14/09,13:33:33] Microsoft .NET Framework 3.5: ***ERRORLOG EVENT*** : Error code 1603 for this component means "Fatal error during installation."
[09/14/09,13:33:33] Setup.exe: AddGlobalCustomProperty
[09/14/09,13:33:33] Microsoft .NET Framework 3.5: ***ERRORLOG EVENT*** : Setup Failed on component Microsoft .NET Framework 3.5

Odd, why won’t the .Net Framework 3.5 install? Shouldn’t be hard to fix by downloading the .Net 3.5 installer and installing it manually. Or should it? That didn’t work, either. Again from the install log.

[09/14/09,13:42:31] WIC Installer: [2] Error code 1603 for this component means "Fatal error during installation."
[09/14/09,13:42:31] WIC Installer: [2] Setup Failed on component WIC Installer
[09/14/09,13:42:33] WapUI: [2] DepCheck indicates WIC Installer is not installed.

What does Windows Imaging Component have to do with anything? Probably nothing, but Windows Installer does, so let’s take that route. I download the latest Windows Installer installer (!) and attempt to install (!!) manually. Too bad that didn’t help, either — but at least this time I got an error message seemed to point me in the right direction.

Setup Error: You do not have permissions to update Windows Server 2003.

Now we’re getting somewhere. Googling that exact error message brought me to a Microsoft knowledge base article (KB888791) which told me:

Update.exe version 5.4.1.0 and later versions require that the user who installs the software update is an administrator with certain user rights.

A quick look at the policy settings on the server showed me that the Administrators group didn’t have the “Back up files and directories” right, as shown below.

A quick request to IT to grant the Administrators group the missing right, and viola! TFS, and other software, is finally installing.

Apparently, this may have been the root cause issue for software not installing or uninstalling properly a week or so ago, when I put in the original request to have the server rebuilt, which leads me to wonder. If Update.exe knows what rights it requires, why doesn’t it check for them, why doesn’t it provide a clear error message indicating what is missing, and why doesn’t this information bubble up appropriately to MSI installers that use Update.exe?

The world may never know.

Debugging ‘Multiple-step operation generated errors’ errors in VB6 and SQL 2005

I just blogged about CSFBL moving to its new server. All was going well, until I tried to kick off the sim engine, a big part of which is written in Visual Basic 6.0 (cringe, I know, but who has time to rewrite legacy code?).

The sim engine is implemented as a DLL which gets invoked via COM. This part works fine; the DLL is activated, properties are sent to it, and it runs… then crashes, with the following obscure error:

Error Number: -2147217887
Description: Multiple-step operation generated errors. Check each status value.

I searched, and searched… nothing. I recompiled, and checked settings… nothing. I prayed, and finally found this post: http://www.developersdex.com/sql/message.asp?p=581&r=4737805

Continue reading