.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 Tagged ‘object’

FIX: A NullReferenceException exception may occur when you set the Table property of a DataView object in a .NET Framework 2.0 application

Symptoms
Consider the following scenario in a Microsoft .NET Framework 2.0 application:You set a DataTable object for the Table property of a DataView object.The DataTable object that you use contains fewer rows than the DataTable object that was previously set for the Table property. The DataView object is bound to a DataGrid object.In this scenario, a NullReferenceException exception may occur.
Resolution
This problem occurs because the DataView object raises a ListChanged event before the DataView object has completed the transition to the new DataTable object.The DataView object tries to access the index for a DataRow object. However, that index is no longer valid because the Table property is set to a different DataTable object.

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 try to save a record in Microsoft Dynamics CRM 4.0: “Object reference not set to an instance of an object”

Symptoms
When you try to save a record in Microsoft Dynamics CRM 4.0, you receive the following error message:

Object reference not set to an instance of an object.If you have enabled platform tracing, you receive an error message that resembles the following:

Application:
MSCRM Error Report:
Error: Exception has been thrown by the target of an invocation.
Error Number: 0×80040265
Error Message: Object reference not set to an instance of an object.
Error Details: Object reference not set to an instance of an object.
Platform.Sdk:
Web Service Plug-in failed in SdkMessageProcessingStepId: {F6D4EBBB-0075-407D-8208-26575BFA39AF}; EntityName: new_businessrules; Stage: 20; MessageName: Create; AssemblyName:
Microsoft.Crm.ObjectModel.MultiCurrencyPlugin, Microsoft.Crm.ObjectModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35; ClassName: Microsoft.Crm.ObjectModel.MultiCurrencyPlugin; Exception:
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Crm.ObjectModel.CalculateBaseMoney.ProcessCalculatedColumns(DynamicEntity entity, BusinessEntity entityPreImage, EntityMetadata entityMetadata, String exchangeRateFieldName, Boolean isCreateOperation, ArrayList unchangedAttributes)
Resolution
This problem occurs because a money attribute is created for the entity. When you do this, Microsoft Dynamics CRM 4.0 creates an exchangerate attribute to work together with the money attribute. The money attribute is published as part of the entity. However, if you delete the money attribute, the exchangerate attribute is not removed. Therefore, when you try to run a Microsoft Dynamics CRM plug-in, the plug-in can find the exchangerate attribute. However, the plug-in cannot find the money attribute.

DEFECT ERROR: Object Reference not set to an Instance of an Object

Symptoms
“Object reference not set to an instance of an object” This error occurs when generating a report for a company that has been deleted from within FRx.
Resolution
This SMR has been fixed in R04670 Service Pack, please check our website () for availability of Service Packs for your General Ledger. You may also sign up for automatic notification of Services on our website .

BUG: You receive an error message when you serialize a DBConcurrencyException object in ADO.NET 1.0

Symptoms
When you serialize a DBConcurrencyException object, the value of the Row property in the serialized version of the object is set to a null value and an exception occurs:

An unhandled exception of type ‘System.NullReferenceException’ occurred in app_name.exe
Additional information: Object reference not set to an instance of an object.
Resolution
Serialization support is not provided for DataRows in this version of Microsoft Visual Studio .NET.

BUG: Cannot Reference Excel 8.0 Object Library from VB 4.0x

Symptoms
Microsoft Visual Basic 4.0x does not allow addition of the Microsoft Excel8.0 Object Library via Tools/References when the Microsoft Excel 5.0 ObjectLibrary is listed there.
Resolution
When adding a new version of an object (or type) library to itsTools/Reference list, Microsoft Visual Basic 4.0x, in spite of thedistinctly different version numbers of the old and new object libraries,insists, via an internal string-comparison routine, that the new library’sLocale/Country ID (LCID) be identical to the old library’s LCID. Becausethe Microsoft Excel 5.0 Object Library has an LCID of 9 (English) and theMicrosoft Excel 8.0 Object Library has an LCID of 0 (Default Language),this test fails; Microsoft Visual Basic 4.0x then displays the error:

“Object library’s language setting incompatible with current project”and does not add the new library to the Tools/Reference list.