Importing a C#.NET dll into Delphi

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sarah_c_clough@hotmail.com

    Importing a C#.NET dll into Delphi

    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

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

    #2
    Re: Importing a C#.NET dll into Delphi

    hi Sarah,

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

    <sarah_c_clough @hotmail.comwro te in message
    news:1180005176 .617650.155450@ o5g2000hsb.goog legroups.com...
    >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
    >

    Comment

    • sarah_c_clough@hotmail.com

      #3
      Re: Importing a C#.NET dll into Delphi


      Aha!

      Thanks.

      Comment

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

        #4
        Re: Importing a C#.NET dll into Delphi

        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

        <sarah_c_clough @hotmail.comwro te in message
        news:1180099261 .534294.66390@u 30g2000hsc.goog legroups.com...
        >
        Aha!
        >
        Thanks.
        >

        Comment

        • sarah_c_clough@hotmail.com

          #5
          Re: Importing a C#.NET dll into Delphi

          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.

          Comment

          Working...