license checking inside Class_Initialize()

I have a VB6 dll that contains a lot of the functions for my asp application. I need to put a license key check inside the dll in order to prevent the app from running if a valid key is not found, or if it's expired.

I would like to put this check inside Class_Initialize() so that it is only executed once -- when the object is created. Is there any danger in this, or pitfalls I should be aware of? Would this create instability in the component or webapp? Is there a better solution? Are there certain types of code that should not be executed inside Class_Initialize()?

Can Class_Initialize() return a value to signify expired or invalid key? Or can it call a function to do so? If not, how can I alert the calling asp page that this is the case?

I will split points for any useful responses.
LVL 11
Who is Participating?
I don't see any issues using Class_Initialize.  I have used it for my own license checking in my components.  There is no way to return a value directly, but you can fill a variable made accessible via a public property that can be accessed once the component is created, e.g.,

Private m_blnLicenseValid As Boolean

Public Property Get LicenseValid() As Boolean
    LicenseValid = m_blnLicenseValid
End Property

Private Sub Class_Initialize()
    'ensure initially false
    m_blnLicenseValid = False

    'do license checking
    'fill m_blnLicenseValid with results
End Sub

From ASP:

Dim obj

Set obj = Server.CreateObject("MyDLL.MyClass")
If obj.LicenseValid = False Then
    Response.Write "Invalid License"
    'proceed with ASP code
End If
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.