views:

194

answers:

3
A: 

The PHP manual states that COM and DOTNET are classes not functions.

You ask how to use these classes. The manual page for each contains detailed descriptions of the constructor arguments along with examples and a fair amount of associated user-contributed documentation.

Do the manual pages not provide what you need?

Jon Cram
Woops, corrected. No, the manual pages aren't helping a whole lot. By the description of proper dotnet() syntax, `$forms = new DOTNET('System.Windows.Forms', 'Form');` should work, even if adding the full 'version' and 'publickeytoken' assembly string. This is what's confusing me.
bob-the-destroyer
+1  A: 

Try this:

$forms = new DOTNET('System.Windows.Forms', 'System.Windows.Forms.Form');

I notice that the examples from the manual use fully-qualified class names.

John Saunders
No luck: "The system cannot find the file specified"
bob-the-destroyer
Are you able to create and run a simple Windows Forms application on the server system? Install [Visual Studio Express](http://www.microsoft.com/express) if necessary to test this. The next most likely answer would be that .NET isn't installed correctly.
John Saunders
@John Just now installed vb express 2010 to try this building a console test app. Within vb, I was able to reference System.Windows.Forms via .Net and use classes and methods from that library to build a form. The test app compiled, installed and executed successfully. Tried again with PHP, still no luck. I then reinstalled .Net. Then tried again with PHP, still no luck.
bob-the-destroyer
@bob: just tried it myself (in a web service) and got an internal server error.
John Saunders
@John OK, although I just got it working, I'm stumped on what caused the problem. `$form = new DOTNET('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=<my_assembly_token>', 'System.Windows.Forms.Form');` works, and `$form->Show();` pops up a form. All I can guess is either the original assembly string I was using had a typo, I wasn't using the full assembly string with the fully-qualified class name before, or reinstalling .net repaired the issue. At any rate, now I understand it, and now I'm off.
bob-the-destroyer
Also, your suggestion to install visual studio express helps a lot as it gives me a platform to quickly look up and test related classes and methods with their descriptions.
bob-the-destroyer
Also, I added a note about this in PHP's DOTNET manual page.
bob-the-destroyer
@bob: I'm thinking that you had more than one version of System.Windows.Forms installed, and needed to specify which.
John Saunders
A: 

Hi, I also need to work with dotnet class. However i got a dll file created by someone else and i need to read its functions and pass some parameters. I have the source for dll. So i know which methods to call and what parameters to pass. I read somewhere that it is possible to read a dll file in php. After google searching for some time now, came across dotnet class.

If anyone has any clue on how to read a external dll file, then please comment. Thanks

noobcode
I can't explain the whole process as I'm not even sure. But as far as I know, in order to get PHP's DOTNET() to work with it, the dll must be registered in the GAC (see: http://en.wikipedia.org/wiki/Global_Assembly_Cache). Before that though, within the dll, you must jump through the required hoops to get your dll classes and methods to be COM visible (see: http://msdn.microsoft.com/en-us/library/zsfww439.aspx). Since you have the source, you can clean it up, set it up for COM usage, recompile, then register in the GAC where DOTNET() can find and use it.
bob-the-destroyer
Thanks a lot bob. This gives me some more information.Appreciated.
noobcode