Calling Managed Code From Unmanaged Code

Posted on 2006-03-29
Last Modified: 2013-12-03
I am working on an MDI application written in Delphi.  All the child documents are in DLL's.  The names of the DLLs are stored in the database so that they can be dynamiclly added into the system.  The all except the same parameter when they are instantiated, an ADO connection string to the database.  Is it possible to write the child documents in C#, compile them into DLL's, and call them from the Delphi parent document without modifing the parent application?
Question by:DMSINTL
    LVL 4

    Accepted Solution

    "Without modifying the parent app" no.

    You cannot create "standard" Win32 DLL's from C# (with the ol' _cdecl or stdcall-type stuff).

    Now, with C++ and Managed Extensions, you might be able to do this. If you want to head down that road, I can get you started, but not much further since that's pretty complicated and hairy stuff.
    LVL 14

    Assisted Solution

    Here's an tutorial on how you can do calls on managed code from unmanaged:
    LVL 4

    Expert Comment

    Yeah, what he said. :)

    You have to be careful though, sometimes you can get into a situation where the CLR isn't loaded at the right time. For *most* purposes that should work, but sometimes you have to actually hook into the DLL init stuff and handle the CLR initialization manually. That gets ugly.
    LVL 4

    Expert Comment

    I think he (existenz2) should get more of the points (maybe 25/75 me/him)? His answer was more useful. Mine was mostly a "Me too" answer.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now