Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Generate COM Component from C#
#1
I used the following C# code to generate a COM component, and then created a COM object in QM,
but I was unable to use the dot notation to display the object's member methods.
demo: https://i.ibb.co/nsXN810z/mycom.gif

What did I do wrong?

Thank you in advance for any suggestions and help.

Function Com_Demo_T
Code:
Copy      Help
out

__ComActivator ca.Activate("MyCom.X.manifest")
IDispatch mc._create("ComDemo.MyComClass")

Function Com_Demo
Code:
Copy      Help
CsScript x.Compile("" "$qm$\MyCom.dll")
out "MyCom.dll is OK!"

1

__ComActivator_CreateManifest "MyCom.dll" 1
out "MyCom.X.manifest is OK!"

#ret
using System;
using System.Runtime.InteropServices;

namespace ComDemo
{
,// Define interface
,[ComVisible(true)]
,[InterfaceType(ComInterfaceType.InterfaceIsDual)]
,[Guid("12345678-1234-4321-ABCD-1234567890AB")]
,public interface IMyComClass
,{
,,int Add(int a, int b);
,,string Hello(string name);
,}

,// Implement COM class
,[ComVisible(true)]
,[ClassInterface(ClassInterfaceType.None)]
,[Guid("ABCD1234-5678-4321-ABCD-1234567890AB")]
,public class MyComClass : IMyComClass
,{
,,public int Add(int a, int b)
,,{
,,,return a + b;
,,}

,,public string Hello(string name)
,,{
,,,return $"Hello, {name}!";
,,}
,}
}

My idea is to create the class object in the qm main function, and then use the class object's member functions directly in other functions, so that the COM component is only called once. Is this possible?


Messages In This Thread
Generate COM Component from C# - by Davider - 06-18-2025, 09:09 AM
RE: Generate COM Component from C# - by Gintaras - 06-18-2025, 09:43 AM
RE: Generate COM Component from C# - by Davider - 06-18-2025, 10:24 AM
RE: Generate COM Component from C# - by Gintaras - 06-18-2025, 11:19 AM
RE: Generate COM Component from C# - by Davider - 06-18-2025, 01:17 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)