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 Tagged ‘activex dlls’

PRB: Cannot Administer Analysis Services by Using DSO in ASP.NET

Symptoms
When you try to use Microsoft Decision Support Objects (DSO) from an ASP.NET application to perform administrative tasks on a server that is running Analysis Services, you may receive an error similar to the following:
When connecting to the local computer that is running Analysis Services:

Cannot connect to the Analysis server on computer ‘MyServer’. Connection to the server is lost
When connecting to a remote computer that is running Analysis Services:

Cannot open connection to Analysis server ‘MyRemoteServer’. Error in data [Possible data corruption]
Resolution
This behavior occurs for two separate reasons. One part of the issue involves the start permissions of the DSO ActiveX DLL. By default, the ActiveX DLLs are carried out in the ASP.NET worker process (Aspnet_wp.exe) under the ASPNET account, when called from an ASPX page.
The other part of the issue is, Aspnet_wp.exe uses a Multi-Threaded Apartment (MTA) model, while DSO uses a Single-Threaded Apartment (STA) model. With the ASP.NET application, the impersonation token is on one of the applications MTA threads and the STA COM component is accessed by a different thread (the single thread in its STA). Because the MTA threads impersonation token is not passed to the STA thread, the STA thread carries out under the security token associated with the Aspnet_wp.exe process.

BUG: Crash When Closing Application That Uses ActiveX DLL

Symptoms
Using Visual Basic, you create one or more ActiveX DLLs and a Standard EXE(client) application to use the DLLs. The client application runs asexpected within the Visual Basic (IDE) environment. However, when youcompile and run the client application as an EXE, the application producesone of the following errors upon closing:

<project name> caused an invalid page fault inmodule MSVBVM50.DLL at 0137:0f059b41.
-or-

Exception: access violation (0xc0000005), Address: 0×0f059b41
Resolution
This problem can occur when the objects you create in the DLL are notclosed properly by the client application due to a circular reference. Acircular reference occurs, for instance, in the following scenario:
A client application instantiates an object in the ActiveX DLL: theParent object. The Parent object creates another object in the DLL: theChild object. The Parent object sets a property in the Child object thatallows the Child object to have a reference to the Parent object.
This creates a circular reference between the Parent and Child objects.When the client application that created the Parent object sets its objectvariable to Nothing, the Parent object does not terminate because the Childobject maintains a reference to the Parent object. The MORE INFORMATIONsection below describes a specific case for this problem and provides asolution, which is to remove the Child’s reference to the Parent objectbefore closing the Parent object.