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 6548103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:54:38+00:00 2026-05-25T11:54:38+00:00

A program I wrote (in C#) accesses through a C++/CLI wrapper library a native

  • 0

A program I wrote (in C#) accesses through a C++/CLI wrapper library a native (c++) library I also wrote.

I noticed that the native library’s DllMain method is called more than once, and the debugger thinks that multiple memory locations are connected to some of the library calls. From what I see, the library is initialized (and memory allocated) more than once.

Given that my code does not use functions such as LoadLibrary, and the dll is used including the library’s .h files and .lib, why is it initialized more than once, and what can I do to avoid it?

  • 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-05-25T11:54:38+00:00Added an answer on May 25, 2026 at 11:54 am

    AFAIK DLL may not be loaded more than once into the same address space. Even if you call LoadLibrary explicitly the DLL won’t be loaded more than once, instead its reference counter is incremented.

    Also I don’t understand exactly what you mean by “debugger thinks that multiple memory locations are connected to some of the library calls“. A single imported symbol (function or a variable address) is filled by just one address during DLL binding.

    I believe you have one of the following:

    • You may load simultaneously multiple versions of the same library (several DLL files). A typical error is to load debug and release DLL versions simultaneously.
    • Your DllMain is called several times, but it does not mean it’s loaded several times. Do you check the parameters supplied to the DllMain? Is it DLL_PROCESS_ATTACH, or perhaps it’s just DLL_THREAD_ATTACH/DLL_THREAD_DETACH?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a simple program that accesses a file called input.txt and pushes its
I wrote a program that forks some processes with fork(). I want to kill
I'm working with a program that accesses an MS-Access DB. The problem is that
I'm developing a small haskell program that uses an external static library I've developed
I have a program I wrote that when it has an error, it saves
Wrote a small app that accesses a bunch of search websites and puts the
I have a program I wrote in C# with a window that contain a
I need to test a program I wrote that receives XML as a text
If using Haskell as a library being called from my C program, what is
Through my Android program I wrote a file like this: String file = Environment.getExternalStorageDirectory().getAbsolutePath()

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.