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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:01:04+00:00 2026-06-14T22:01:04+00:00

I have an application whose core functionality is contained within a (C) DLL. Header

  • 0

I have an application whose core functionality is contained within a (C) DLL. Header files exist for this library’s exports. This application is very much single-instanced. By that I mean, the library internally uses a lot of global state, as it is only meant to work on one file at a time. The normal workflow the application uses with this library is this:

  1. Init

  2. Open database

  3. Work with database

  4. Close database

    (Repeat)

I want to write a .NET object model around the functionality this library provides. By this, I mean I want "database" to be an object (call it Database), which has properties/methods that boil down to the library calls.

I would of course want to be able to have multiple Database objects at any given time. However, there can be one instance of this library loaded into my process (I assume), and I am then limited by the library’s use of global variables.

What are my options?


I considered making my top-level class Database accessible only via a factory method, which would limit the number of instances of Database to only one:

public class Database {
    private Database() {
       library_init();
       // ...
    }

    private Database m_instance;

    public static Database Open(string file) {
         if (m_instance != null)
             throw new InvalidOperationException("...");
         return new Database();
    }

    public Close() {
        library_close();
        // ...
        m_instance = null;
    }
}

Is there anything else I can do, like load the library manually in a separate AppDomain or something like that?

I really only foresee needing one instance at a time, but it would be nice to not have to live with that restriction.

  • 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-14T22:01:05+00:00Added an answer on June 14, 2026 at 10:01 pm

    If that global state is in RAM only (i.e. the DLL uses no hardcoded file names/registry keys for the state), then I see 2 options how to use several instances:

    1. (quick & dirty) Rename the DLL and load it under another name. This may fail due to many reason, e.g. due to the state of some dependent DLLs, or explicit checks..

    2. (generally more correct, but harder) Create an EXE that loads your C DLL, and exposes the functionality as some IPC API, e.g. as a WCF service with named pipe binding. Then, spawn several instances of that EXE process, and use WCF to call the API.

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

Sidebar

Related Questions

I have a GUI application whose main part is a QPlainTextEdit . It is
In my WPF application I have a CheckBox whose IsChecked value is bound to
I have a C# Windows Forms application, whose prototype was created on SQL Server
In my application, I have a listview whose list item consists of a TextView
I have application with needs to have access to some sensitive data(in this case
I have a Java application whose UI relies heavily on audio. On Windows and
I have a Zend Framework application whose sole purpose is to serve as an
I am developing an application whose front-end is built using jquery mobile. This application
This is probably a very straight forward application, but I am new to Objective-C
Let's assume I have an application whose dimensions are larger than the user's screen

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.