xsharp.eu • OLEAutoObjectEx
Page 1 of 1

OLEAutoObjectEx

Posted: Thu Jan 14, 2021 12:08 pm
by Jores
Hello,

How to use OLEAutoObjectEx in X# ?
When compiled, the result is:
error XS0246: The type or namespace name 'OLEAutoObjectEx' could not be found (are you missing a using directive or an assembly reference?)

Best regards.
Georgi Georgiev  
 

OLEAutoObjectEx

Posted: Thu Jan 14, 2021 2:33 pm
by robert
Georgi,
This class is indeed not part of our runtime (yet).
Can you try it with OleAutoObject ?
What extra functionality are you using from OleAutoObjectEx?

Robert

OLEAutoObjectEx

Posted: Fri Jan 15, 2021 9:13 am
by Jores
Hello, Mr. Robert,

I use many functions written in .Net and called via COM.
I can transfer them to X#, but first I want to fix the other errors.
I will use the OLEAutoObject class to continue the transfer.

Thanks for the quick response and for the X# software!

Best regards.
Georgi Georgiev  
 

OLEAutoObjectEx

Posted: Fri Jan 15, 2021 9:51 am
by Meinhard
Hi Georgi!

The class OleAutoObjectEx was introduced to VO by me in 2.8 SP4 to make accessing COM components a little more variable. Actually you don't need that and can stick to OleAutoObject. But, if you're COM components are written in .Net, you don't need to use this class. simply refer to the implementing assembly in your X# program and use the classes in there directly! Faster and more reliable, as you omit all the untyped stuff in the OleAutoObject area.

Regards
Meinhard

OLEAutoObjectEx

Posted: Tue Jan 19, 2021 12:35 pm
by Jores
Hello, Mr. Meinhard,

Thanks for the reply.

COM components are written in .Net
Could you give an example of direct use of classes?

Best regards.
Georgi Georgiev

OLEAutoObjectEx

Posted: Tue Jan 19, 2021 2:50 pm
by Meinhard
Hi Georgi,

depends, do you own the source of the .net part of the COM components? I would need to know what classes and interfaces are implemented in the .net assembly which way has been used to register them with COM.
In Principle this usually works similar to this (sample of my own a COM component to show Google maps nad cosume Google Map Api from VO) :

    [ComVisible(true)]
    [Guid("a specific guid")]
    [ClassInterface(ClassInterfaceType.None)]
    [ProgId("GMapConnector.GMapConnectorClass")]
    public class GMapConnector :IGMapConnector
    {
        public virtual string ShowMap(IGMapParameterObject parameter)
        {
          ....
        }
    }

  and 

    [ComVisible(true)]
    [Guid("yet another specific guid")]
    [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    public interface IGMapConnector    
    {
        [DispId(1)]
        string ShowMap(IGMapParameterObject parameter);
        .....
    }

Then, after generating the classes inside the VO IDE you can use this like :

    local connector as IGMapConnector

    connector := IGMapConnector{}    
    if connector:fInit
    ....
    endif

Where IGMapConnector is the generated class and inherited from OleAutoObject(ex).

Now, the interface is just a kind of meta information for the COM marshalling process to call the corresponding method in the implementing class (GMapConnector ) correctly. Therefor it not neccessary in the .net Environment. In X# for example (after adding the correspronding assembly to your project) you can do:

local connector := GMapConnector{} as IGMapConnector

This way you talk to the implementing class directly without all the COM overhead.

HTH & Regards
Meinhard
  

 

OLEAutoObjectEx

Posted: Mon Jan 25, 2021 10:41 am
by Jores
Hello, Mr. Meinhard,

Thank you very much for the example you wrote.

Best regards.
Georgi Georgiev