Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8496611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:54:07+00:00 2026-06-10T23:54:07+00:00

I need to load a DLL from within another DLL. The temptation is to

  • 0

I need to load a DLL from within another DLL. The temptation is to load it in DllMain, but there is already convincing documentation which says that it is a “bad idea”.

At the risk of asking a question that is not very specific: Is there a best practice of loading a DLL from another DLL?

In our current project, our main DLL has a class. I load the second DLL from the constructor of that class. However, since that class can be instantiated multiple times in the DLL, I keep a variable around that indicates whether the DLL was previously loaded in order not to call LoadLibrary again. This somehow doesn’t feel like it is a good solution, hence my question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:54:08+00:00Added an answer on June 10, 2026 at 11:54 pm

    It depends on your DLL.
    Basically, you have these options:

    1. Link against that DLL’s LIB to load it automatically
    2. Load the other DLL when your library is loaded, unload before it’s unloaded
    3. Load the other DLL before use, then unload

    If you choose 1, you’ll get really weird messages, if DLL2 is missing when you try to load DLL1, something like “Failed to load DLL1”. And the customer will never know that it’s because of missing DLL2. So I don’t like to use this solution, if you are not 100% sure that DLL2 is correctly installed.

    When you load DLL2 by hand (LoadLibrary), however, you get a chance to present a meaningful message.

    You can choose 2 if you have clear entry and exit points in your DLL. This is the case if your DLL exports one or very few functions, i.e. a function to create factory for other objects. Then you can load/unload with the factory.

    You can choose 3, if this doesn’t cause you to do this load/unload frequently.

    Futhermore, you have no need to keep only one handle to DLL2. You can call LoadLibrary/FreeLibrary multiple times, and it’s the framework who does the reference counting.

    So, as your situation allows, you can choose one of these 3 solutions. You’ll have to use your original solution only if you have no clear entry point and you are calling the function, which requires DLL2, too often.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to load some resource from my DLL (i need to load them
I have a case where I need to load bitmap from a resource dll
Two Delphi programs need to load foo.dll, which contains some code that injects a
I need to load a custom function from an extern file but without causing
I need to load some .Xnb files from a DLL in a Xna Game.
I need to load a lot of data fetched from a mysql db in
I need to load an image from a web in a simple Java stand
I need to load a model, existing of +/- 20 tables from the database
I need to load an xslt from a database and hold it in memory
I need to remotely load a .NET DLL that contains an ActiveX object (non-visual)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.