I'm using a C#.NET DLL with ASP.NET 2.0 and it's working now. I want to use the same DLL in PHP.
I'm a newbie in PHP; would someone please tell me how to use it in PHP or could you share some example?
I'm using a C#.NET DLL with ASP.NET 2.0 and it's working now. I want to use the same DLL in PHP.
I'm a newbie in PHP; would someone please tell me how to use it in PHP or could you share some example?
PHP has a built-in Windows-only extension called DOTNET that allows you to use .NET libraries in a PHP application.
Note that you'll need to make sure your assemblies are declared as COM visible:
[assembly: ComVisible(true)]
Here are two examples.
<?php
$stack = new DOTNET("mscorlib", "System.Collections.Stack");
$stack->Push(".Net");
$stack->Push("Hello ");
echo $stack->Pop() . $stack->Pop();
?>
Another example demonstrating functionality of DOTNET class:
<?php
$full_assembly_string = 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a8425bc35256e463';
$full_class_name = 'System.Windows.Forms.Form';
$form = new DOTNET($full_assembly_string, $full_class_name);
// code to add buttons, menus, text, etc
$form->Show();
$form_event = '';
while($form_event !== 'close') {
// handle form functions and events
}
?>
you are using the PHP Version 5.4.7 you should already have com_dotnet.dll if you dont have it you can download it on "download" and add to your ext/ path inside php directory.
Edit you php.ini file
extension=php_com_dotnet.dll
What you really need is this:
(you find those tools most probably in "C:\Program Files (x86)\Microsoft SDKs\Windows\ ...", just google for their correct use, easy enough)
<?php
// use this kind of name, not path to dll or whatever
// print your assemblly's full name in .NET and use that
$name = "YourAssembly, Version=1.1.1.1, Culture=neutral, PublicKeyToken=fe6263478ac";
$obj = new DOTNET($name, "YourNamespace.YourClass");
echo "success\n";
?>
Oh yeah, vaibhav is right about "php.ini". I didn't have to edit it. It had the correct values (defaults maybe?).