Page 1 of 1

how to add System.Component library

PostPosted: September 19th, 2006, 9:53 am
by phalanger@codeplex
Hi,
I'm a new to Phalanger.
Pls tell me how to include System.ComponentModel Libraray to phalanger? This library is not added in my machine.config file.can you tell me how to add this library to run my code?
Thanks...

RE: how to add System.Component library

PostPosted: September 20th, 2006, 9:18 am
by Lada Prosek
Types from the System.ComponentModel are implemented in the framework assembly called "System", which is added to machine.config during install. You should be able to use these types right away.

<?  $x = new System:::ComponentModel:::DateTimeConverter;  echo $x->ConvertFromString("Aug 1 2006");?>

or

<?  import namespace System:::ComponentModel;   $x = new DateTimeConverter;  echo $x->ConvertFromString("Aug 1 2006");?>

RE: how to add System.Component library

PostPosted: September 22nd, 2006, 11:47 am
by nagraj@codeplex
<?php

import namespace System:::Drawing;

......
........

$x=new Image("sample.image");

......
.....
?>

This will generate an error saying
Instantiation of abstract class or interface 'System:::Drawing:::Image'


RE: how to add System.Component library

PostPosted: September 22nd, 2006, 1:52 pm
by Lada Prosek
The Image class is abstract.

[SerializableAttribute] [ComVisibleAttribute(true)] public abstract class Image : MarshalByRefObject, ISerializable, ICloneable, IDisposable

RE: how to add System.Component library

PostPosted: September 25th, 2006, 7:27 am
by nagraj@codeplex
could you give more information

RE: how to add System.Component library

PostPosted: September 25th, 2006, 9:47 am
by Lada Prosek
MSDN: Abstract classes act as expressions of general concepts from which more specific classes can be derived. You cannot create an object of an abstract class type; however, you can use pointers and references to abstract class types.

Image cannot be instantiated, but you can create instances of its subclasses (aka derived classes), namely Bitmap and Metafile.

<?  $x = new System:::Drawing:::Bitmap("C:\\Windows\\Gone Fishing.bmp");  var_dump($x instanceof System:::Drawing:::Bitmap);  var_dump($x instanceof System:::Drawing:::Image);?>

This prints true twice, because the Bitmap is obviously a Bitmap and it is also an Image because Bitmap is derived from Image. You can still use Image in situations like this:

  function PrintImage(System:::Drawing:::Image $image)  {    // ...  }

The typehint says that the function can be called with anything that is in Image, i.e. both an instance of Bitmap and an instance of Metafile would be valid arguments.

RE: how to add System.Component library

PostPosted: September 26th, 2006, 12:23 pm
by nagraj@codeplex
thanks,

it got worked.