.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 ‘error message’

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.

BUG: AppDomainUnloaded exception when you use managed extensions for Visual C++ components

Symptoms
This problem occurs when a call is made from unmanaged code to managed code, including direct unmanaged-to-managed calls within a single DLL. For example, the problem may occur when MEC++/IJW is used in ASP.NET applications. In ASP.NET, various events can cause applications to be reloaded into a new AppDomain. If you are using MEC++ components and IJW in this application, you may receive an AppDomainUnloadException error message.
Resolution
As part of the implementation of IJW, when a managed DLL that you created by using the C++ compiler loads, the runtime creates thunks for transitions from unmanaged code to managed code. These thunks contain a reference to the AppDomain in which the DLL loads. The runtime does not re-create these thunks if the DLL loads again; also, the runtime does not update the reference when the original AppDomain unloads and the DLL loads in another AppDomain.
When the program performs a transition from unmanaged code to managed code, the program uses the outdated AppDomain reference to run the managed code. Even if the original AppDomain is still loaded, the code cannot access static fields because the fields are specific to the AppDomain.

BUG: “Index was out of range” error message when you access a Visual Basic .NET 2002 collection object that implements IList with -1 Base

Symptoms
When you use the IList interface with a Visual Basic .NET collection object in Visual Basic .NET (2002) before you use the Insert property, you can insert elements in the list at index -1. If you insert an element at index -1, you receive the following error message when you try to read the element by using the Item property at index -1:

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Resolution
The IList index has a base of -1 instead of zero. Therefore, you can insert an element at index -1 even though MSDN documentation states that the IList index is zero-based. However, you receive an error when you try to read the value from the IList at index -1.

BUG: “Attempt to Access the Method Failed” Error Message When You Use a Reference to the Wrong Microsoft Forms 2.0 Object Library

Symptoms
In a Visual Studio .NET project that contains a reference to the Microsoft Forms 2.0 Object Library, you may receive an error message similar to the following:

System.MethodAccessException: “Attempt to access the method failed.”
Resolution
When you use the Add Reference dialog box to add a reference to the Microsoft Forms 2.0 Object Library, you may notice that two entries appear for Microsoft Forms 2.0 Object Library.Both of these entries refer to the FM20.dll file.
You must select the first Microsoft Forms 2.0 Object Library entry in the list because this is the Primary Interop Assembly (PIA) reference. If you select the second Microsoft Forms 2.0 Object Library entry, your application may not behave as expected.

ACC2000: VBA Functions Break in Database with Missing References

Symptoms
If you have a procedure that contains a Visual Basic for Applicationsfunction, and your database contains a reference to a missing objectlibrary or type library, you may receive the following error message whenyou compile your modules or run the procedure:

Compile Error:
Can’t find project or library
Resolution
Your database contains a reference to a database, type library, or objectlibrary that is marked as MISSING: <referencename> in the References dialog box.

ACC2000: Properties Collection Returns Error for CurrentProject and CurrentData Objects

Symptoms
All object collections under the CurrentProject and CurrentData objects contain a Properties collection. However, when you try to refer to the Properties collection of any object in a collection under the CurrentProject or CurrentData object, you may receive the following error message:

Run-time error ‘2467′:
The expression you entered refers to an object that is closed or doesn’t exist.
Resolution
Although you cannot use the Properties collection to refer to properties of these objects, you can refer to the properties directly. For example, use:

Debug.Print CurrentData.AllTables(1).Name instead of:

Debug.Print CurrentData.AllTables(1).Properties(“Name”)