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. C / C++ / MFC
  4. Newbie - Memory sharing in COM

Newbie - Memory sharing in COM

Scheduled Pinned Locked Moved C / C++ / MFC
questioncomsysadminperformancehelp
9 Posts 3 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.
  • J Offline
    J Offline
    jayart
    wrote on last edited by
    #1

    Hi, I have a doubt regarding memory sharing in a COM object. Background: Recently we shifted to VS2005. Hence the dll written in VC6 is no longer directly useful. I might have to write a COM wrapper to access this dll. The application would be working with huge files and I want only a single copy maintained across my application. The dll should actually read the file and after the error checking send the a pointer of the memory to my application. My question: 1) Is it possible to do it with COM? 2) What would happen if my COM object memory is on a remote server? 3) Does the COM object copy the memory and send it to the requested application or does it just pass the reference. My intention is to maintain a single place of memory where the file data would be read and used. Please let me know how can I achieve this through COM. Any links would be useful. Regards, Arti Gujare

    L 1 Reply Last reply
    0
    • J jayart

      Hi, I have a doubt regarding memory sharing in a COM object. Background: Recently we shifted to VS2005. Hence the dll written in VC6 is no longer directly useful. I might have to write a COM wrapper to access this dll. The application would be working with huge files and I want only a single copy maintained across my application. The dll should actually read the file and after the error checking send the a pointer of the memory to my application. My question: 1) Is it possible to do it with COM? 2) What would happen if my COM object memory is on a remote server? 3) Does the COM object copy the memory and send it to the requested application or does it just pass the reference. My intention is to maintain a single place of memory where the file data would be read and used. Please let me know how can I achieve this through COM. Any links would be useful. Regards, Arti Gujare

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      ArtiGujare wrote:

      Recently we shifted to VS2005. Hence the dll written in VC6 is no longer directly useful.

      I don't understand that? Your old C++ code should be able to still do the following in a VS2005 C++ project.

      ArtiGujare wrote:

      The dll should actually read the file and after the error checking send the a pointer of the memory to my application.

      led mike

      J 1 Reply Last reply
      0
      • L led mike

        ArtiGujare wrote:

        Recently we shifted to VS2005. Hence the dll written in VC6 is no longer directly useful.

        I don't understand that? Your old C++ code should be able to still do the following in a VS2005 C++ project.

        ArtiGujare wrote:

        The dll should actually read the file and after the error checking send the a pointer of the memory to my application.

        led mike

        J Offline
        J Offline
        jayart
        wrote on last edited by
        #3

        When I said we shifted to VS2005 I meant that the application using the dll was previosly written in VC6 and dll too was written in VC6. Now the application has to be written in VS2005 and still use the VC6 dll. My typical use case is: 1) Application send the file name to the dll. 2) dll reads the file at that mentioned filepath and does some file checks 3) if the file is in expected format, the dll returns the pointer pointing to the file data to the applictaion. I hope it looks clear now.

        L 1 Reply Last reply
        0
        • J jayart

          When I said we shifted to VS2005 I meant that the application using the dll was previosly written in VC6 and dll too was written in VC6. Now the application has to be written in VS2005 and still use the VC6 dll. My typical use case is: 1) Application send the file name to the dll. 2) dll reads the file at that mentioned filepath and does some file checks 3) if the file is in expected format, the dll returns the pointer pointing to the file data to the applictaion. I hope it looks clear now.

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          I see no information in there that would keep you from accomplishing that using VS2005 C++ projects.

          led mike

          J 1 Reply Last reply
          0
          • L led mike

            I see no information in there that would keep you from accomplishing that using VS2005 C++ projects.

            led mike

            J Offline
            J Offline
            jayart
            wrote on last edited by
            #5

            What about : 2) What would happen if my COM object memory is on a remote server? 3) Does the COM object copy the memory and send it to the requested application or does it just pass the reference.

            L 1 Reply Last reply
            0
            • J jayart

              What about : 2) What would happen if my COM object memory is on a remote server? 3) Does the COM object copy the memory and send it to the requested application or does it just pass the reference.

              L Offline
              L Offline
              led mike
              wrote on last edited by
              #6

              For (3): You cannot pass a reference to memory across machines, that makes no sense at all. Therefore the memory is copied. I have no idea why you are fixated on COM. Nothing in your requirments demands using COM. Without a requirement I would not choose to include the complexity and overhead associated with COM. In other words I would only use COM as a last resort.

              led mike

              J 1 Reply Last reply
              0
              • L led mike

                For (3): You cannot pass a reference to memory across machines, that makes no sense at all. Therefore the memory is copied. I have no idea why you are fixated on COM. Nothing in your requirments demands using COM. Without a requirement I would not choose to include the complexity and overhead associated with COM. In other words I would only use COM as a last resort.

                led mike

                J Offline
                J Offline
                jayart
                wrote on last edited by
                #7

                Hi Led, I tried adding the VC6dll in my VS2005App using "Add Reference". I could not add it. I got the message "A reference to "" could not be added. Please make sure that the file is accesible, and that it is a valid assembly or COM component" I googled around a bit with this message and I found that I cannot simply use the VC6dll in my VS2005App. Many links suggested that I might have to wrap the dll in a COM component in order to use it. Hence the COM usage. Otherwise if there is an alternative to bypass COM wrapping I would be more than happy to do the same. Any suggestions? Thanks and Regards, Arti Gujare

                M L 2 Replies Last reply
                0
                • J jayart

                  Hi Led, I tried adding the VC6dll in my VS2005App using "Add Reference". I could not add it. I got the message "A reference to "" could not be added. Please make sure that the file is accesible, and that it is a valid assembly or COM component" I googled around a bit with this message and I found that I cannot simply use the VC6dll in my VS2005App. Many links suggested that I might have to wrap the dll in a COM component in order to use it. Hence the COM usage. Otherwise if there is an alternative to bypass COM wrapping I would be more than happy to do the same. Any suggestions? Thanks and Regards, Arti Gujare

                  M Offline
                  M Offline
                  Mark Salsbery
                  wrote on last edited by
                  #8

                  Is the DLL already implementing a COM object? If so then it should work no problem. I thought one of the ideas behind com was portable objects. If it's not a com DLL then there's no "Add Reference" that will load the DLL. You need to link to it (implicitely or explicitely using LoadLibrary() or similar). If it uses MFC you may have problems. If it uses the CRT you may have problems as well since you'll have mixed versions between the app and the DLL. Mark

                  1 Reply Last reply
                  0
                  • J jayart

                    Hi Led, I tried adding the VC6dll in my VS2005App using "Add Reference". I could not add it. I got the message "A reference to "" could not be added. Please make sure that the file is accesible, and that it is a valid assembly or COM component" I googled around a bit with this message and I found that I cannot simply use the VC6dll in my VS2005App. Many links suggested that I might have to wrap the dll in a COM component in order to use it. Hence the COM usage. Otherwise if there is an alternative to bypass COM wrapping I would be more than happy to do the same. Any suggestions? Thanks and Regards, Arti Gujare

                    L Offline
                    L Offline
                    led mike
                    wrote on last edited by
                    #9

                    ArtiGujare wrote:

                    I tried adding the VC6dll in my VS2005App using "Add Reference".

                    "Add Reference" is for adding .NET assemblies in a "Managed" Project. You are in the C++ forum indicating that your project is a "Native" project. Therefore you do not add a reference to the DLL. You link to it using a .Lib file just as before. Using a DLL from a C++ project is pretty basic stuff, why are you having problems with this? Perhaps if you give us more information about your level of experience we might provide more targeted information.

                    led mike

                    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