Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Singleton ?

Singleton ?

Scheduled Pinned Locked Moved .NET (Core and Framework)
question
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fregolo52
    wrote on last edited by
    #1

    Hello, I want to share datas managed in a DLL that is called by 2 different applications. Someone said me sometimes a DLL with singleton can have 2 instances. An other solutions exists ? thanks Freg

    J J 2 Replies Last reply
    0
    • F fregolo52

      Hello, I want to share datas managed in a DLL that is called by 2 different applications. Someone said me sometimes a DLL with singleton can have 2 instances. An other solutions exists ? thanks Freg

      J Offline
      J Offline
      Josh Smith
      wrote on last edited by
      #2

      When a DLL is used by a process, a "fresh copy" of it is loaded into that processes address space. The singleton instance of a class in one process is a separate entity from the singleton instance in another process. What you could do is use .NET remoting to host a singleton instance of your class. When either of your apps needs to access that truly unique instance, it would request it from the remoting service. If you need more info about remoting and singleton activation, CP has some great articles on that subject. Josh

      1 Reply Last reply
      0
      • F fregolo52

        Hello, I want to share datas managed in a DLL that is called by 2 different applications. Someone said me sometimes a DLL with singleton can have 2 instances. An other solutions exists ? thanks Freg

        J Offline
        J Offline
        Jun Du
        wrote on last edited by
        #3

        Are these applications running on the same machine or on a network? Best, Jun

        F 1 Reply Last reply
        0
        • J Jun Du

          Are these applications running on the same machine or on a network? Best, Jun

          F Offline
          F Offline
          fregolo52
          wrote on last edited by
          #4

          On the same machine

          J F 2 Replies Last reply
          0
          • F fregolo52

            On the same machine

            J Offline
            J Offline
            Jun Du
            wrote on last edited by
            #5

            Then it looks like a typical IPC case. In theory, all IPC mechanisms may work for your purpose, but "shared memory" should be an effective solution for significant amount of data sharing. On Windows platform, it's implemented as "memory-mapped files" or MMF. An MMF is a kernel object that maps a disk file to certain memory block of your process address space so that multiple processes/DLLs can access the same data as if they were accesing its own process data. Google "sheared memory" or "memory-mapped file" to get yourself on the track. If you need more guidance, drop a line here. Best, Jun

            1 Reply Last reply
            0
            • F fregolo52

              On the same machine

              F Offline
              F Offline
              Felipe Dalorzo
              wrote on last edited by
              #6

              The smallest deployment unit that exist in .NET is an assembly, but when you create an assembly (*.dll, *.exe), this makes them like small islands to comunicate them you need to use things like .NET Remoting to be able to let them talk, but the use of such power solution will make sense only if you are talking about processes(running in the back) or executable applications because either a private or public dll can be used in many applications at the same time with no problems. Hope this help

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups