Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

.net com object

0 views
Skip to first unread message

nos...@nospam.com

unread,
May 14, 2005, 1:29:53 PM5/14/05
to
Hello,

I have a com object that I need ported over to .net. They dont go over
too easy, since there is no .net equilivilant of ComSrv. Yet I cant figure
out how to create a com object in delphi for .net.

Can anyone help?


Marc Rohloff [TeamB]

unread,
May 14, 2005, 3:34:53 PM5/14/05
to

> Can anyone help?
Creating COM objects in .NET is very different to Delphi.
Basically any object can be surfaced as a COM object. Use the
ComVisible attribute to specify what you want to be visible via COM
(Classes, methods, properties) and give your class a Guid attribute.
After compiling your assembly use RegAsm to register it.


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

nos...@nospam.com

unread,
May 14, 2005, 8:21:16 PM5/14/05
to
Thanks Marc,

I set the ComVisible to true and gave it a guid, I still can not reg the
dll with regsvr32. Since Im new to .net can you fill in here to give me a
jump start?

Class1.pas has a class in it I want to expose to com....

library comtest;


{%DelphiDotNetAssemblyCompiler
'$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.dll'}
{%DelphiDotNetAssemblyCompiler
'$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.Data.dll'}
{%DelphiDotNetAssemblyCompiler
'$(SystemRoot)\microsoft.net\framework\v1.1.4322\System.XML.dll'}

uses
SysUtils,
Classes,
System.Reflection,
System.Runtime.InteropServices,
Class1 in 'Class1.pas'; <-want to expose class1.testproc()

//other assembly code generated by delphi

[assembly: ComVisible(True)]
[assembly: Guid('E0782317-10A6-4CB3-B9F1-A3616CDFEDAF')]
[assembly: TypeLibVersion(1, 0)]

begin
//do I put something here to make the procs visible?

end.

Thanks again Marc.


"Marc Rohloff [TeamB]" <"on request"> wrote in message
news:4lkuyky4...@marcrohloff.40tude.net...

Marc Rohloff [TeamB]

unread,
May 14, 2005, 8:32:34 PM5/14/05
to
On Sat, 14 May 2005 20:21:16 -0400, nos...@nospam.com wrote:

> I set the ComVisible to true and gave it a guid, I still can not reg the
> dll with regsvr32. Since Im new to .net can you fill in here to give me a
> jump start?

You need to use regasm to register .NET assemblies for COM. If you are
using Delphi 2005 you can also use tregsvr.

You probably want to read this:
http://blogs.borland.com/cbensen/archive/2004/12/08/2111.aspx

nos...@nospam.com

unread,
May 14, 2005, 10:11:53 PM5/14/05
to
Thanks Marc,

Eventually, this com object needs to be called from jscript using the
createObject( myInterface.myClass) function

(Its for a windows media center plug in ). Am I on the right path to be
able to do that using the techique you described?

thanks,
Rich

"Marc Rohloff [TeamB]" <"on request"> wrote in message

news:rljhzokq333n$.dlg@marcrohloff.40tude.net...

Marc Rohloff [TeamB]

unread,
May 14, 2005, 10:32:55 PM5/14/05
to
On Sat, 14 May 2005 22:11:53 -0400, nos...@nospam.com wrote:

> (Its for a windows media center plug in ). Am I on the right path to be
> able to do that using the techique you described?

AFAIK, Yes.

nos...@nospam.com

unread,
May 14, 2005, 11:09:17 PM5/14/05
to
Thanks Marc, Youre the best!

p.s. What does AFAIK mean?

"Marc Rohloff [TeamB]" <"on request"> wrote in message

news:1a2hqp0g...@marcrohloff.40tude.net...

Carl Caulkett

unread,
May 15, 2005, 6:01:09 AM5/15/05
to
<nos...@nospam.com> wrote:

> Thanks Marc, Youre the best!
>
> p.s. What does AFAIK mean?

AFAIK, it means "As far as I know"

--
Carl

0 new messages