Implement ObjectControl Interface to Use GetObjectContext()

Implement ObjectControl Interface to Use GetObjectContext()

A Visual Basic class module provides an Initialize procedure. The code you write in Initialize is executed when the Visual Basic object is created. However, Initialize is always executed before the object has been activated. This means that you can’t successfully call GetObjectContext in Initialize. A call to GetObjectContext in Initialize won’t experience a runtime error–it will simply return a null reference. However, you will get a runtime error, when you try to access a property or a method using this null reference.

The Terminate procedure in a Visual Basic class is executed prior to the object’s destruction and after the object has been deactivated. Terminate is similar to Initialize in that you can’t successfully call GetObjectContext in this procedure. These two procedures supplied by Visual Basic don’t give you all the control you need to manage your object’s life cycle in the MTS environment.

The MTS run time can help by notifying your object just after activation and once again just before deactivation. The MTS type library includes a definition for an interface named ObjectControl. When the MTS run time creates an MTS object, it calls QueryInterface to determine whether the object supports this interface. If an MTS object implements ObjectControl, the MTS run time calls methods in this interface to notify the object at important transition stages during its life cycle. This means that you should implement ObjectControl in every object that needs to receive these notifications. The ObjectControl interface contains the three methods: Activate, Deactivate, and CanBePooled. Activate is called by the MTS run time after activation and just before the first method call is executed. Deactivate is called by the MTS run time just before the object is switched out of the context wrapper. CanBePooled is called by the MTS run time after deactivation and just before the object is destroyed. To receive these notifications, you should implement the ObjectControl interface in the MultiUse class modules in your ActiveX DLLs.

Share the Post:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as