What is the correct syntax for instantiating a COM object in Delphi Prism using COM interop - new does not seem to do the job.
I've added it as a reference to the website project. Here is the relevant code:
method _Default.Button1_Click(sender: System.Object; e: System.EventArgs);
var
FModel: MarketBuilderLib.MarketBuilderModel;
begin
FModel := New MarketBuilderLib.MarketBuilderModel;
end;
Fails to compile with the message:
Error 1
(PE190) "MarketBuilderLib.MarketBuilderModel" is an interface and cannot be
instantiated
I understand the message but not sure how to do it. Many thanks for any help.
You can attempt to instantiate your COM object by using the CreateInstance method in the System.Activator class. The equivalent code might look like this:
Note that you will need to get the type from GetTypeFromProgID using the Program Identifier otherwise you will generate an InvalidComObjectException.