Com objects made with .net 2.0

Com objects made with .net 2.0

Post by Dimitar St » Wed, 19 Dec 2007 18:41:11


Hi,

I have a problem with creating a COM object with RAD Studio 2007 .NET . this
is the sample:

uses
Classes,
System.Runtime.InteropServices;

type
[ComVisible(True)]
[Guid('277e1f84-a8e9-11dc-8314-0800200c9a66')]
IrdmA = interface
[dispId(1)]
function GetStr : string;
end;

[ComVisible(True)]
[ClassInterface(ClassInterfaceType.None)]
[Guid('38da2e1c-a8e9-11dc-8314-0800200c9a66')]
TrdmA = class(TObject, IrdmA)
private
public
constructor Create();
function GetStr : string;
end;
.......

The instatiation of the COM object is made by a win32 delphi application and
an error "Access Violation at 0x78158984: write of address 0x00030ffc" is
raised. Strange but if the instantiation is made by a .net appication,
everithing is working fine.I investigated the problem and found that if I
comment out Classes unit from uses section the COM object is created
successfully. But I need Classes unit in my real application...

Can you tell me, what should I do?

Thanks in advance.

Regards
Dimitar Stoyanov
 
 
 

Com objects made with .net 2.0

Post by Marc Rohlo » Wed, 19 Dec 2007 23:12:47


<snip>


So, in your sample you get the error just by using 'classes' and not
actually using any functions in it? Then it must be something in the
initialization section of 'classes' or one of the units it uses.
You could test this by making a copy and commenting out code
gradually.

The simplest solution seems to be to just copy the methods you need
out of classes into a new unit.

--
Marc Rohloff [TeamB]
marc -at- marc rohloff -dot- com