Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何解决重新加载(从图像读取条形码)时发生的php中的com_异常错误?_Php_Com - Fatal编程技术网

如何解决重新加载(从图像读取条形码)时发生的php中的com_异常错误?

如何解决重新加载(从图像读取条形码)时发生的php中的com_异常错误?,php,com,Php,Com,我正在使用clear image SDK从图像中读取条形码。代码仅在我的浏览器上第一次起作用。当我重新加载页面时,它抛出一个异常。为了使它再次工作,我重新启动了我的web服务器,它再次工作。但是当我重新加载页面时,它再次抛出相同的异常。错误如下所示: ( ! ) Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> ClearImage.ClearImage.1<br

我正在使用clear image SDK从图像中读取条形码。代码仅在我的浏览器上第一次起作用。当我重新加载页面时,它抛出一个异常。为了使它再次工作,我重新启动了我的web服务器,它再次工作。但是当我重新加载页面时,它再次抛出相同的异常。错误如下所示:

( ! ) Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> ClearImage.ClearImage.1<br/><b>Description:</b> SEH Exception 0xC0000005' in C:\wamp\www\test.php on line 11
( ! ) com_exception: <b>Source:</b> ClearImage.ClearImage.1<br/><b>Description:</b> SEH Exception 0xC0000005 in C:\wamp\www\test.php on line 11
(!)致命错误:未捕获异常“com_exception”,在第11行的C:\wamp\www\test.php中显示消息“Source:ClearImage.ClearImage.1
描述:SEH异常0xC0000005” (!)com_异常:来源:ClearImage.ClearImage.1
描述:第11行C:\wamp\www\test.php中的SEH异常0xC0000005
如果我从命令行调用脚本,它可以正常工作,如果我再次调用脚本也没关系。我根本不需要重新启动Web服务器

这个脚本到底是怎么回事?我是否需要关闭脚本中的任何特定资源或连接,以便它可以再次工作?这是我第一次使用COM对象

<?php
try {
    // To insert line breaks in HTML output replace \n with <br>
    // Create and Configure ClearImage Object
    $Ci = new COM("ClearImage.ClearImage");
} catch (Exception $e) {

    echo $e->getMessage();
}
// Create the 1D Barcode Pro object. Use any of the other engines here.
$Bc = $Ci->CreateBarcodePro();
// Open file.
$File = 'c39.tif'; // Use YOUR file name

$File = 'C:\\test.jpg';
$Bc->Image->Open($File);
// $Bc->Code39 = true;
// Set reading parameters. Update values if needed. See Online API help
$Bc->AutoDetect1D = 65535;

/*
 * my testing
 */
$Bc->Type = 2;

$Bc->Directions = 2;
$Bc->Algorithm = 2;
/*
 * my tesing
 */
$Bc->Algorithm = 2;

// Read Barcodes
$BCcount = $Bc->Find(0);
echo "\nBarcodes: $BCcount\n";
if ($BCcount == 0) {
    $Msg = "No barcodes found in $File \n";
    exit($Msg);
}
for ($i = 1; $i <= $BCcount; $i ++) {
    echo "Barcode #$i ";
    $FBc = $Bc->BarCodes($i);
    // NOTE: Text value will terminate on the first null in data
    echo "Type: $FBc->Type Length: $FBc->Length\n";
    echo "Barcode Value: $FBc->Text \n";
    echo " Binary Data in Hex: \n ";
    $hex_ary = array();
    $cnt = 0;
    foreach ($FBc->Data as $chr) {
        $hex_ary[] = sprintf("%02X", $chr);
        $cnt = $cnt + 1;
        if ($cnt == 16)         // break lines after 16 numbers
{
            $hex_ary[] = sprintf("\n");
            $cnt = 0;
        }
    }
    echo implode(' ', $hex_ary);
    echo "\n";
}

unset($Ci);

第11行是哪一行?此处引用的错误代码表示访问冲突,即通过空指针或无效指针访问内存。是否在重新加载页面时,页面中存储的某些引用被重置或无效?它应该是$Bc=$Ci->CreateBarcodePro();