Page 1 of 1

PHP and DCOM

Posted: Mon Nov 12, 2007 1:35 am
by eblackmo
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have the following code;

Code: Select all

<?
	$objMetaFrameFarm = new COM("MetaFrameCOM.MetaFrameFarm");
	$objMetaFrameFarm->Initialize(1);
	
	$objTheSessions = $objMetaFrameFarm->Sessions;
		
	print $objMetaFrameFarm->FarmName;
	$objMetaFrameServers = $objMetaFrameFarm->Servers;
	
	try
	{
		
		foreach($objMetaFrameServers as $objMetaFrameServer)
		{
			echo $objMetaFrameServer->ServerName;
		}
	}
	catch (com_exception $x)
	{
		print $x . "\n";
	}
	


?>
If I run it as is I get a http 500 error if I comment out the foreach the code seems to run fine. If I then add $count = $objTheSessions->Count; inside the try it throws the following useful error;

exception 'com_exception' with message 'Source: Unknown
Description: Unknown' in C:\Inetpub\wwwroot\Citrix_test_again.php:19 Stack trace: #0 C:\Inetpub\wwwroot\Citrix_test_again.php(19): unknown() #1 {main}

Count is a property of the Sessions object. print $objMetaFrameFarm->FarmName; works correctly and is output to the browser.

I was under the impression that foreach allows you to traverse a collection like for each in vb but this does not seem to be the case the sessions object does implement a _NewEnum property which returns an enumerator (ienumvariant) object for the collection I'm having some difficulty with the syntax though......

Does anyone have any suggestions? Thanks.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]