Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Registering and using a .NET DLL from within Delphi (XE2)

Registering and using a .NET DLL from within Delphi (XE2)

Registering and using a .NET DLL from within Delphi (XE2)

Hi -

Some time ago, I developed a small app to communicate with some hardware using a DLL (supplied by the manufacturers of the hardware.) Recently however, they decided to re-write the API and wrap it in a .NET DLL. Now its been hell to try use this thing.

Here is an extract from an email relating to this issue..

Quote (Supplier)

"We have chosen not to continue forward with the ActiveX OCX technology ..Rather a .Net-compliant DLL that is fully compatible with Win XP/7 (32/64-bit) and Win8.x 64-bit platforms. This solution does not require system registration and in this aspect alone, we feel makes this solution superior to the ActiveX environment..."

Although they say that the DLL does not need to be registered - is this correct ? I was led to believe that to use a .NET DLL from withing my software it would first have to be registered (using Regasm ?).

I have googled this issue but not found anything very helpful. They supplied 2 files a DLL and a Type file (.tlb) I tried importing the .Net assembly into delphi (not sure it I did it right - or if indeed I needed to) and it produced a .pas file that I place in the uses section and it seems to work (after a fashion.)

Here is a link to the delephi-created wrapper for the .NET assembly..


Now I have it working on 1 computer.. using the following code..

In the "OnCreate" event on the main form I have..

CODE --> Delphi

Drawer  : USBQFUMC_;
Drawer := CoUSBQFUMCCLS.Create as USBQFUMC_;

Now as I say, I have got this running on 1 computer - but I am having problems installing it on other computers (all are using Windows 8.1.) On the other computer I tried to install it on - I get an error relating to the fact the Class or DLL is not registered. I have tried many ways of using regasm to try remedy this - but none seem to work.

Can someone please tell me if I am going about this all wrong - or is there an easier (not reliable) way to get this working ? IS there any way to access the .NET DLL from within delphi WITHOUT registering the .DLL (as the supplier implied ?)

Any help would be much appreciated..

Many thanks..


RE: Registering and using a .NET DLL from within Delphi (XE2)

Seems odd that you have it working on one computer, since the supplier states that they do not longer provide and ActiveX/OCX.
I suspected you still have the old DLL registered on that machine.
The only way you can interface with a native .NET DLL is from .NET.
What I usually do is make an intermediary COM visible .NET DLL that consumes the real .NET DLL and expose the wanted functionality through the COM interface.


Helping people is my job...

RE: Registering and using a .NET DLL from within Delphi (XE2)

Thanks for the tip regarding Hydra - but at $400 - its not a realistic solution for me. The problem is that I have had very little to do with COM or .NET so both technologies are new to me, so Im afraid the solution Daddy's solution is not gong to help me much.

I think that the reason 1 computer seemed to work ok and the others didn't is probably to do with OS-specific stuff (privileges etc..)

I know its not because the old DLL is registered as its the new code that worked - not the old code

Quote (old code)

"..dllHandle := LoadLibrary(PChar(DLLPath));"

If anyone has some reasonably easy-to-follow code I will be all ears :). Also will it be necessary to use regasm to register the DLL before use ? Or are they correct when they say it needs no registration ?


RE: Registering and using a .NET DLL from within Delphi (XE2)

Ok, I slow down and think with me please.

If I look on this page,
I can see that there are 2 versions :

- APG USBQFUMC v1.00 : this is a COM visible .NET DLL which needs to be registered via the .NET RegAsm tool as instructed by the documentation.
- APG USBQFDNETSUSN v110 : this is a pure .NET DLL which can not be registered with RegAsm as it does not expose a COM interface (and therefore cannot be consumed in Delphi).

So what version are you attempting to use?


Helping people is my job...

RE: Registering and using a .NET DLL from within Delphi (XE2)

Hi Daddy -

I have been using the USBQFUMC.DLL version. As I say, I did ,manage to get it working on 1 comp after a fashion - just cant seem to get it working on 2 other similar configured computers (all use Windows 8.1.)

I think the problem may be with registering it on the OS. I am not 100% sure of the correct command line arguments, but it does seem to register ok (it generates no error messages anyway.) I first tried using Inno to register it during a test installation. When it came up with errors using the App I wrote - I tried registering it manually from the command line. Here is one such attempt..

CODE --> Dos

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe C:\ctest\USBQFUMC.dll 

This comes back that all went well, but then I get a "ClassID " OLE error when trying to use. I have tried using the 32-bit version of Regasm (In case this was an issue) I have even tried running the different versions of Regasm (based on the various installations of .NET installed - 2 and 4.) Nothing seems to make any difference.

The error message thrown when trying to use the App does not help either. Did Google the code and I think it says "list out of bounds error" or some such. Sounds like a best-guess error message to me. The OLE error is : 80131508.

Here is a screen shot of it..

Anyway, thanks for continued help m8 - its much appreciated :).


RE: Registering and using a .NET DLL from within Delphi (XE2)

I don't know if it helps but the docs state clearly you must use the /codebase parameter.
What that parameter essentially does is write the path where the DLL resides into the registry.
If you omit the parameter, the DLL will be copied to the GAC and registered from there.

Can you tell what line is throwing the error you are seeing?


Helping people is my job...

RE: Registering and using a .NET DLL from within Delphi (XE2)

Hi -

I think I have used nearly every variation of the Regasm commandline I think. However, I may have used the "/codebase" parameter using Inno script (not sure if I have used it manually - so maybe I can give that a go.

The line that generates the error I posted is where I first attempt to create an instance of the object in my app. Here is the line that generates the error..

CODE --> delphi

Drawer  : USBQFUMC_;
Drawer := CoUSBQFUMCCLS.Create as USBQFUMC_;


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close