expose Phalanger .dll as COM component ?
4 posts
• Page 1 of 1
expose Phalanger .dll as COM component ?
Can you give a simple example of how to expose a class and member method in a Phalanger .dll to COM? I am trying to write a COM add-in for Microsoft Retail Management System which looks for a COM exposed function named "Process()"... works great in VB.net but can't get it working with Phalanger. I have tried to adapt C# examples to PHP but I am having no luck. Any help would be greatly appreciated. Sample code below:
<?php
use System;
use System\Windows\Forms;
use System\Runtime\InteropServices;
[\Export]
[assembly: System\Runtime\InteropServices\ComVisible(true)]
class RMStoPMSLibraryClass
{
function __construct(){
}
[System\Runtime\InteropServices\ComVisible(true)]
public function Process(System\Object $QSSession){
Forms\MessageBox::Show('Sample Message Box in Phalanger');
return TRUE;
}//close function process()
}//close RMStoPMSLibraryClass
?>
<?php
use System;
use System\Windows\Forms;
use System\Runtime\InteropServices;
[\Export]
[assembly: System\Runtime\InteropServices\ComVisible(true)]
class RMStoPMSLibraryClass
{
function __construct(){
}
[System\Runtime\InteropServices\ComVisible(true)]
public function Process(System\Object $QSSession){
Forms\MessageBox::Show('Sample Message Box in Phalanger');
return TRUE;
}//close function process()
}//close RMStoPMSLibraryClass
?>
- spencer hollon
- Posts: 5
- Joined: April 8th, 2014, 5:40 pm
Re: expose Phalanger .dll as COM component ?
Phalanger produces standard .NET assemblies, but anything explicitly about COM components.
You may add Guid, InterfaceType and ProgId attributes as well. Also I've added \Export attribute for the whole assembly (all classes will be emitted with nice .NET interface).
Please note, compiled assembly has to be registered for COM interop
Do you have a working sample in VB or C#?
You may add Guid, InterfaceType and ProgId attributes as well. Also I've added \Export attribute for the whole assembly (all classes will be emitted with nice .NET interface).
Please note, compiled assembly has to be registered for COM interop
- Code: Select all
regasm "PathToDll.dll" /codebase /tlb
- Code: Select all
<?php
use System;
use System\Runtime\InteropServices;
[assembly: \Export] // emits nice C# public methods
[assembly: InteropServices\ComVisible(true)]
[InteropServices\Guid('7BD20046-DF8C-44A6-8F6B-687FAA26FA88')]
class RMStoPMSLibraryClass {
function __construct() {}
[InteropServices\ComVisible(true)]
public function Process(System\Object $QSSession){
System\Windows\Forms\MessageBox::Show('Sample Message Box in Phalanger');
return TRUE;
}
}
Do you have a working sample in VB or C#?
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: expose Phalanger .dll as COM component ?
Thank you Jakub. Using OLE/COM viewer my public functions are exposed now.
- spencer hollon
- Posts: 5
- Joined: April 8th, 2014, 5:40 pm
Re: expose Phalanger .dll as COM component ?
Great! Do you have a sample project?
Thanks,
Thanks,
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
4 posts
• Page 1 of 1
Return to PHP/C# interoperability
Who is online
Users browsing this forum: No registered users and 0 guests