Importing a C#.NET dll into Delphi

S

sarah_c_clough

I have a dll created in C#.net, that I wish to call from Delphi 5. I
have strong-named the assembly, deployed it in the GAC, and registered
it with RegAsm, but whenever I create the pas file (either through the
'Import Type Library' option in Delphi, or via an InteropUtils program
I found on the web) it does not contain any types. In the 'const'
section in the pas file there is one GUID for the dll, but nothing
else, and there is no 'type' section at all.

Can somebody tell me where my problem lies, whether it's how I create
my dll, or am I missing a step before creating it and deploying it
into the GAC, or is there something I need to do before creating the
pas? (I'm pretty sure it's not the latter of these three, as when I
use the Delphi 'import type library', no classes are shown in the
'class names' box).

When I run RegAsm, I have to use the tlb option otherwise it tells me
'No types were registered'. I don't know if this is related, or what
it's telling me.

I tried disassembling the dll using ildasm, then reassembling it using
ilasm, based on a tip I found on the internet, but after I've done
that I can't put it in the GAC as the strong-naming appears to become
invalidated.

Thanks.
Sarah
 
I

Ignacio Machin \( .NET/ C# MVP \)

hi Sarah,

Are you checking the "Register for COM Interop" checkmark? in the project
config options?
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

That is the easiest way, but you should do it correctly and generate a guid
and place the correct directives in the assemblyinfo.cs file.

I do not have with me right now a project with all these features but will
get it for you on monday
 
S

sarah_c_clough

I can now access the class and functions in my COM dll. However, it's
a visual control, how do I get it to actually appear? It appears fine
if I call the dll from another .NET project, but if I call if from
Delphi, I can't get it to appear. What do I have to do differently?
At the moment I just initialise the class.

Cheers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top