Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2009
    Posts
    1

    Unanswered: PHP and VB COM dll

    Hi,

    I am trying to connect to a COM component using PHP, but keep on recieving an "Unexpected error has occured" message.

    The COM component code is

    Code:
    Option Explicit
    
    Public Enum ApplicationErr
        Unexpected = Error.Unexpected
    End Enum
    
    Private Const m_csClassName As String = "XYZ.Application"
    
    Public Sub Initialize(ByVal udl As String, ByVal log)
    On Error GoTo ErrInitialize
        Dim enumErrorCode As xyzError
        enumErrorCode = Success
        
        Dim oObjectContext As ObjectContext
        Set oObjectContext = GetObjectContext()
        
        oObjectContext("Session")("ConString") = "FILE NAME=" & App.Path & "\" & udl
        oObjectContext("Session")("ErrLog") = App.Path & "\" & log
        
    ExitInitialize:
        On Error Resume Next
        Set oObjectContext = Nothing
        If enumErrorCode <> Success Then
            On Error GoTo 0
            Call Err.Raise(enumErrorCode, m_csClassName, GetErrorDescription(enumErrorCode))
        End If
        Exit Sub
    ErrInitialize:
        If Err.Source = m_csClassName Then
            enumErrorCode = Err.Number
        Else
            enumErrorCode = Unexpected
        End If
        If Not (Err.Source = "XYZ.Application" And Err.Number = XYZ.ApplicationErr.Unexpected) Then Call LogError(m_csClassName & ".Initialize")
        Resume ExitInitialize
    End Sub
    The PHP code used is :

    PHP Code:
    <?php

    try {
    $udl = new VARIANT("XYZ.udl",VT_BSTR);
    $errorlog = new VARIANT("ErrorLog.txt",VT_BSTR); 

    $Q = new COM("XYZ.Application") or die("Cannot start XYZ");
    $lUserId $Q->Initialize($udl,$errorlog);

    echo 
    $lUserId;

    catch (
    com_exception $e
    {
    $lUserId = array('errorCode' => $e->getCode(),
    'errorMessage' => $e->getMessage(),
    'errorFile' => $e->getFile(),
    'errorLine' => $e->getLine());
    }

    echo 
    "<pre>";
    print_r($lUserId);
    echo 
    "</pre>";
    ?>
    It always generates an exception. Can someone please help me resolve this issue.

    Also could it be a Type mismatch error?

    thanks.
    Last edited by amey72; 02-05-09 at 02:45.

  2. #2
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    It looks like it's the COM object giving you that exception error, rather than PHP performing an error. I'd also expect something to be in your PHP logs if you were getting a PHP error.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •