Visual Basic Q&A

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 December, 2010

PRB: Jet 4.0 Row-Level Locking Is Not Available with DAO 3.60

Symptoms
According to Microsoft Knowledge Base article 275561?(http://support.microsoft.com/kb/275561/EN-US/) “ACC2000: New Features in Microsoft Jet 4.0″:
To minimize the impact of the increased page size and respond to a long-standing request from developers building applications based on the Microsoft Jet database engine, row-level locking was added to Jet 4.0.However, row-level locking of an Access database is not available with Data Access Objects (DAO) 3.60.
Resolution
To resolve this problem, use ActiveX Data Objects (ADO) to enable row-level locking on an Access database, and then open DAO connections to the database. All subsequent attempts to open DAO connections to the database will respect the locking mode that you set.

PRB: InvalidCastException When You Bind Office XP Web Component on a .NET Windows Form

Symptoms
When you bind an Office XP Web Component to another Office XP Web Component for a DataSource at run time, you receive the following error message:

An unhandled exception of type ‘System.InvalidCastException’ occurred in <YourWindowsApplication.exe>
Additional information: Specified cast is not valid.You might receive this error when you bind a Spreadsheet Component, a PivotTable Component, or a Chart Component to one of the other Office Web Components. For example, the following line of code generates the error:

AxChartspace1.DataSource = AxSpreadsheet1
Resolution
To resolve this problem, set the DataSource property for the component to the object that the GetOcx method of the control returns, which is intended to act as the DataSource. The following is an example:

AxChartspace1.DataSource = AxSpreadsheet1.GetOcx()

PRB: IntelliSense Features Do Not Appear in Visual Basic 6.0 for .NET COM Interop Components

Symptoms
When you register a Microsoft Visual Basic .NET Component for COM Interop in the registry by using the Register for COM Interop option in Visual Studio .NET, the IntelliSense features for the methods and properties of the classes do not appear in your Visual Basic 6.0 application. Also, you cannot use early binding to bind to a method or a property.
Resolution
This problem occurs in the following scenario:When you use the Register for COM Interop option, the Visual Studio .NET build process calls the Regasm tool with the /TLB and /CODEBASE options to register the .NET Component for COM Interop.When you call to the Regasm tool, Visual Studio .NET creates a type library and a COM Callable Wrapper (CCW) Interop assembly.The type library is registered and acts as a COM object to gain access to the .NET assembly.By default, the Regasm tool creates a type library that exposes a non-dual, empty IDispatch interface. Therefore, you cannot use early binding. If you do not use early binding, the IntelliSense features do not appear.

PRB: Instantiating Object in .exe Starts Another .exe Instance

Symptoms
When you instantiate a COM component in an out-of-process server (.exe)from Active Server Pages (ASP), another instance of the .exe starts.
Resolution
The default Identity of a COM component in an .exe is the Launching User.The implication of this is that when the Active Server Pages page tries tocreate an instance of this object, it is doing so in the security contextof the anonymous user (IUSR_<machine name>). If this is a different userfrom the user that started the instance of the .exe that is currentlyrunning, another instance of the .exe starts.