.NET Questions and Solutions

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries for April, 2010

Error message when you use a startup script to start the SQL Server PowerShell provider in SQL Server 2008: “Set-Location: Object reference not set to an instance of an object”

Symptoms
Microsoft SQL Server 2008 installs the SQL Server PowerShell (SQLPS) provider as a feature. When you use a startup script to start the SQL Server PowerShell provider separately without using the SQLPS minishell, the SQL Server PowerShell provider does not let you navigate the SQL Server object hierarchy. Instead, you receive the following exception error message:

Set-Location: Object reference not set to an instance of an object.
Resolution
The SQL Server PowerShell provider requires certain global variables to exist. Typically, the SQLPS minishell sets these global variables. However, when you use a startup script to start the SQL Server PowerShell provider, these global variables are not declared.

Error message when you use a map to transform messages in a BizTalk Server orchestration: “Uncaught exception (see the ‘inner exception’ below) has suspended an instance of service”

Symptoms
Consider the following scenario:You create a map in a Microsoft BizTalk Server project. The map uses an XSL for Transformations (XSLT) file that is defined inthe Custom XSL Path Grid Properties. The map uses the XSLT fileto transformmessages. You use the map in an orchestration to process messages.In this scenario, messages may be suspended. Additionally, you may receive an error message that resembles the following in the Application log:

Event Type: Error
Event Source: XLANG/s
Event Category: None
Event ID: 10030
Description:Uncaught exception (see the ‘inner exception’ below) has suspended an instance of service ‘BizTalk orchestration’.The service instance will remain suspended until administratively resumed or terminated. If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.InstanceId: instance id
Shape name: shape name
ShapeId: shape id
Exception thrown from: segment number, progress number
Inner exception: Error encountered while executing the transform project name.map name. Error:Unable to create the transform.The “Additional error information” section of the error message contains error information that resembles the following:

Resolving of external URIs was prohibited.
Resolution
This issue can occur if the XSLT file that is definedin the Custom XSL Path Grid Properties uses the<xsl:import> element or the <xsl:include> element to import or to include an external XSLT file.

Error message when you upgrade to Microsoft Dynamics CRM 4.0: “Exception has been thrown by the target of an invocation”

Symptoms
When you upgrade to Microsoft Dynamics CRM 4.0, the upgrade process cannot be completed. Additionally, you receive the following error message in the CRM40setup.log file:

Time|Info| Updating precision and scale of decimal attributes
Time|Error| System.Exception: Action
Microsoft.Crm.Setup.Server.InstallDatabaseAction failed. —>
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.Data.SqlClient.SqlException: The statistics ‘hind_1090102924_1A_2A_4A_9A_15A’ is dependent on column ‘Quantity’.
ALTER TABLE ALTER COLUMN Quantity failed because one or more objects access this column.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.Crm.CrmDbConnection.InternalExecuteNonQuery(IDbCommand command)
at Microsoft.Crm.CrmDbConnection.ExecuteNonQuery(IDbCommand command, Boolean impersonate)
at Microsoft.Crm.CrmDbConnection.ExecuteNonQuery(IDbCommand command)
at Microsoft.Crm.Setup.DiffBuilder.UpdatePrecisionAndScaleOnDecimalAttributes()
— End of inner exception stack trace —
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at Microsoft.Crm.Setup.Database.DllMethodAction.Execute()
at Microsoft.Crm.Setup.Database.DatabaseInstaller.ExecuteReleases(ReleaseCollection releases, Int32 currentProgress)
at Microsoft.Crm.Setup.Database.DatabaseInstaller.installInternal()
at Microsoft.Crm.Setup.Database.DatabaseInstaller.Install(Int32 languageCode, String configurationFilePath, Boolean upgradeDatabase)
at Microsoft.Crm.Setup.Server.InstallDatabaseAction.Do(IDictionary parameters)
at Microsoft.Crm.Setup.Common.Action.ExecuteAction(Action action, IDictionary parameters, Boolean undo)
— End of inner exception stack trace —, Error, RetryCancel, Option1Note By default, the CRM40setup.log file is in the following folder:
C:\Documents and Settings\upgrading user\Application Data\Microsoft\MSCRM\logs
This problem occurs if you have custom statistics in the OrgName_MSCRM database.
Resolution
This problem occurs because the upgrade process cannot handle custom statistics in the OrgName_MSCRM database.

Error message when you upgrade Microsoft Dynamics CRM 3.0 to Microsoft Dynamics CRM 4.0: “Unable to resolve related entity for report upgrade”

Symptoms
When you delete a custom entity that has a linked report in Microsoft Dynamics CRM 3.0, and then you upgrade Microsoft Dynamics CRM 3.0 to Microsoft Dynamics CRM 4.0, you receive the following error message in the CRM40Setup.log file:

Time|Error| Unable to resolve related entity for report upgrade.The entity may have been added then deleted without updating the report reference.
Report name: Activities Due, Entity logical name: activity
Time|Error| Unable to upgrade reports.System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Crm.Setup.Server.Utility.ReportUpgradeUtility.BuildRelatedEntitiesValue(String reportName, String relatedEntitiesXml, Guid organizationId)
at Microsoft.Crm.Reporting.ReportUpgradeServer.GetReportProperties(String reportName, String organizationName, Guid organizationId)
at Microsoft.Crm.Setup.Server.Utility.ReportUpgradeUtility.LoadReportProperties(ReportUpgradeServer reportUpgradeServer, Hashtable propertiesByName, String organizationName, Guid organizationId, String reportingGroup)
at Microsoft.Crm.Setup.Server.Utility.ReportUpgradeUtility.LoadReports(ReportUpgradeServer reportUpgradeServer, String organizationName, Guid organizationId, String reportingGroup)
at Microsoft.Crm.Setup.Server.Utility.ReportUpgradeUtility.UpgradeReportsFromVersion3(String organizationUniqueName, String organizationFriendlyName, String reportingGroup, Int32 languageCode, InstallInfo installInfo, IProgressEventSource progress)
at Microsoft.Crm.Setup.Server.RSUpgradeAction.Do(IDictionary parameters)
Resolution
This problem occurs because a report is linked to an entity that does not exist.

Error message when you update a database by using a stored procedure: “System.Data.DBConcurrencyException”

Symptoms
When you use a DataAdapter object to write changes back to a database by means of a stored procedure, you may receive the following error message:

An unhandled exception of type ‘System.Data.DBConcurrencyException’ occurred in system.data.dll
Additional information: Concurrency violation: the UpdateCommand affected 0 records. If the data is not updated correctly, you should receive a DataConcurrencyException exception instead of the above-mentioned error message.
Resolution
This problem can occur if the stored procedure runs the SET NOCOUNT ON statement.

Error message when you try to view the service calendar in Microsoft Dynamics CRM 3.0: “An unhandled exception was generated during the execution of the current web request”

Symptoms
You cannot view the service calendar in Microsoft Dynamics CRM 3.0. Additionally,you receive the following error message:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Resolution
This problem occurs when you have working hours set in Microsoft Dynamics CRM 3.0 and when one of the following conditions is true: You change time zones on your computer.You change from daylight saving time to standard time,or you change fromstandard time to daylight saving time.